Skip to Main Content

Breadcrumb

May 4th

Question and Answer

Connor McDonald

Thanks for the question, Jack.

Asked: July 22, 2016 - 6:50 pm UTC

Last updated: July 22, 2016 - 7:40 pm UTC

Version: 11

Viewed 1000+ times

You Asked

Hello,

I have package that create objects and variables on the package header spec, such as:

CREATE OR REPLACE PACKAGE Test_Package AS

bVariable BOOLEAN := FALSE;

END Test_Package;

Am I correct in assuming that Test_Package.bVariable will be a different instance for every session that connects to the database?

Is there a way to create a variable that would be publicly visible across all connections?

Appreciated your help.

and Connor said...

Yes you are correct. The package variables are "global" to a session, not the entire database.

For a truly "global" variable, check out global application contexts

https://docs.oracle.com/database/121/DBSEG/app_context.htm

Is this answer out of date? If it is, please let us know via a Comment

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library