Skip to Main Content

Oracle Database Discussions

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!

How to declare a global variable from a PL/SQL package

user4184769Jul 19 2010 — edited Jul 20 2010
Hi All,

Using a global variable is a bad practise for all language. However, in my case, I have a PL/SQL package defines all constants, and I want to use them directly via SQL statement, for instance,
PACKAGE my_const
IS
     DEFAULT_ZIP_CODE CONSTANT VARCHAR2(5) := '00000'; 
END;
And I cannot referrence this variable from my select statement as
SELECT my_const.DEFAULT_ZIP_CODE from dual;
I have to create a function via my package, as,
FUNCTION get_default_zip_code RETURN VARCHAR2 
IS
BEGIN
     RETURN DEFAULT_ZIP_CODE; 
END;
and
SELECT my_const.get_default_zip_code from dual;
I don't want to create functions to referrence the default varaibles. Does anyone have any clues?

thanks

Edited by: user4184769 on Jul 19, 2010 8:36 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 17 2010
Added on Jul 19 2010
26 comments
28,971 views