Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Private package global variables

Re: Private package global variables

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Fri, 9 Jan 2004 15:15:44 -0500
Message-ID: <EaqdnVWsk7ZolmKiRVn-tw@comcast.com>

"Ubiquitous" <weberm_at_polaris.net> wrote in message news:btmu5l$9fr$3_at_news.utelfla.com...
| I have a package containing several procedures which have some variables
| in common. For efficiency's sake, I want to make these into private
package
| body globals, but I have a question about how constants operate. If I
declared
| a constant which was initialized to SYSDATE, does the value keep the
compile
| value or is it recalculated each time a procedure within the package is
| executed?

|

sysdate acts like function -- it will return the current date when the variable is initialized at runtime (did you try testing it?)

SQL> create or replace package var_init_test   2 is
  3 procedure show;
  4 end var_init_test;
  5 /

SQL> create or replace package body var_init_test   2 is
  3 the_date date default sysdate;
  4

  5     procedure show
  6     is
  7     begin
  8       dbms_output.put_line(to_char(the_date, 'mm/dd/yyyy hh:mi:ss am'));
  9     end show;

 10
 11 end var_init_test;
 12 /

SQL> set serveroutput on
SQL> exec var_init_test.show
01/09/2004 03:13:29 pm

SQL> exec var_init_test.show
01/09/2004 03:13:29 pm

SQL> disconnect
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option
JServer Release 8.1.7.0.0 - Production

SQL> connect scott/tiger
Connected.

SQL> set serveroutput on

SQL> exec var_init_test.show
01/09/2004 03:13:50 pm

-- 
Mark C. Stock
mcstock -> enquery(dot)com
www.enquery.com training & consulting
Received on Fri Jan 09 2004 - 14:15:44 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US