Re: Are PL/SQL variable values runtime only?

From: David Lord <dlordster_at_gmail.com>
Date: Wed, 22 Jul 2009 20:22:13 +0100
Message-Id: <93726FB7-A3EB-47CC-B5D9-F9470E2B78E7_at_gmail.com>



Hi,

Is this what you're after:

Constants and variables are initialized every time a block or subprogram is entered. By default, variables are initialized to NULL. Whether public or private, constants and variables declared in a package spec are initialized only once for each session.

(Taken from the usage notes here: http://download.oracle.com/docs/cd/ B19306_01/appdev.102/b14261/constantvar_declaration.htm#sthref2587)

Regards
David Lord

On 22 Gorff 2009, at 17:28, Rich Jesse wrote:

> Hey all,
>
> In 10.1.0.5.0, I have a procedure like this:
>
> CREATE OR REPLACE PROCEDURE bleah AS
> v_test VARCHAR2(50) := my_pkg.my_value('ABC');
> BEGIN
> DBMS_OUTPUT.PUT_LINE(v_test);
> END bleah;
> /
>
> ...where "my_pkg.my_value" is a function that reads a table and
> returns a
> column value of a row based on the supplied parameter, in this case
> 'ABC'.
>
> From testing, I can change the column value for row 'ABC' in that
> table (and
> COMMIT) and the above procedure will reflect the change.
>
> I would have suspected the v_test variable value to be retrieve at
> compile
> time, but I suppose that would be a maintenance nightmare since an
> invalid
> referenced object forces a recompile, right?
>
> Also the CONSTANT keyword in the variable declaration does not
> appear to
> effect this behavior.
>
> Is this documented somewhere? I've poked around the PL/SQL User's
> Guide,
> but can't find it.
>
> TIA,
> Rich
>
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Jul 22 2009 - 14:22:13 CDT

Original text of this message