Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A private package body scope question...

Status
Not open for further replies.

weberm

Programmer
Dec 23, 2002
240
US
I have a package containing several procedures which use the same constants. I want to make these into private package body globals so I only have to declare them once, but I have a question about how constants operate. One variable in question is a constant which is initialized to SYSDATE in each of the procedures. If I make it into a global, will the value be updated whenever a procedure within the package is executed, or is the value bound at compile time and never changes?
 
SYSDATE is a function call. Therefore, the constant will be set at execution time.

Elbert, CO
1216 MST
 
Weberm,

Oracle initializes global variables in a package upon initial invocation for a SESSION. The variable value PERSISTS at its most recent setting throughout the life of the SESSION.

Oracle initializes private variables in a package upon each invocation of the procedure/function/package body; the value of the "private" variable does not persist across invocations (i.e., past the "end;" of the module which controls the scope of the variable).

In either case, the value of SYSDATE at compile time is NOT hardcoded into the code; what is compiled is the command to access SYSDATE upon invocation of the package/procedure. Then the "life" of the value follows the rules, above.

Please follow up if this does not answer your question satisfactorily.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 19:18 (09Jan04) GMT, 12:18 (09Jan04) Mountain Time)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top