Re: Persistence in Oracle Packages
Date: 19 Jan 1999 05:58:46 GMT
Message-ID: <19990119005846.00827.00000536_at_ng-cf1.aol.com>
>I've got a couple of stored procedures (proc a and proc b) that I want to
>place in a single package. I want to call proc a, which will set some
>persistent variable x within the package, and exit. Then, later on, I want to
>call proc b, and I want proc b to have access to variable x. In other words,
>I want the variable x to be persistent while the package is in memory. Of
>course, anyone else who calls this package will have their own copy of the
>package.
>
>Is this possible? How is it done? This means there must be some sort of
>constructor type method, right?
>
>Thanks,
>Salaam Yitbarek
Yes it is possible, and used a lot. to do it, in the package body do something like this:
create or replace package body my_pack
x integer;
procedure a (in_value integer) is
begin
x:= in_value;
end;
procedure b (in_value integer) is
new_value integer;
begin
new_value := x + in_value;
end;
end;
Any variable declared outside the scope of a proc of function is visible to all proc and function inside that package, but not visible to anything outside the package.
Hope that helps
Dan Hekimian-Williams
Received on Tue Jan 19 1999 - 06:58:46 CET