Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

When is global variable initialized? - Found the mystery

xxsawerMar 29 2012 — edited Mar 29 2012
Hello I have this problem
Say I create package like this:
CREATE OR REPLACE PACKATE TEST_PACKAGE

PROCEDURE TEST(RetCode OUT VARCHAR2);

END TEST_PACKAGE;
CREATE OR REPLACE PACKATE BODY TEST_PACKAGE

gvc_String VARCHAR2(20) := 'abc'

PROCEDURE TEST(RetCode OUT VARCHAR2) IS
BEGIN
RetCode := gvc_String;
END;

END TEST_PACKAGE;
Now I create an anonymou block like this
DECLARE
RetCode VARCHAR2(20);
BEGIN

TEST_PACKAGE.TEST(RetCode);
DBMS_OUTPUT.PUT_LINE(RetCode);

END;
The problem is that nothing is printed. RetCode is null. It looks like the global variable is not initialized at the moment I am calling the test procedure... But why? It should be initialized as soon as I touch the package, right?

EDITED...

Edited by: xxsawer on 29.3.2012 8:12

Edited by: xxsawer on 29.3.2012 9:13
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 26 2012
Added on Mar 29 2012
11 comments
1,658 views