Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scope of Oracle package level variables

Tags:

Given the following Oracle (10g) package definition:

create or replace PACKAGE "foo" AS     bar VARCHAR2(32000) := NULL;  END; 

what is the scope of bar? Does each session get its own foo.bar, or is foo.bar global across sessions?

Can you quote me chapter and verse from a reference document?

like image 468
tpdi Avatar asked Mar 04 '10 22:03

tpdi


People also ask

What are the advantages of packages in Oracle?

Advantages of PL/SQL PackagesPackages let you encapsulate logically related types, items, and subprograms in a named PL/SQL module. Each package is easy to understand, and the interfaces between packages are simple, clear, and well defined. This aids application development.

What is package level variable?

Package variables are shared, global state. All accessors of that variable will be accessing the exact same memory. It does not matter what type the package variable is, struct / string / int etc. If it is defined at package level, all accessors of that variable will share the same instance of it.

What are global variables in package Oracle?

any variable defined outside of a procedure/function is a global variable and maintains its state for the duration of the session.

What is scope of a variable declared in a package body?

The package spec contains public declarations. The scope of these declarations is local to your database schema and global to the package. So, the declared items are accessible from your application and from anywhere in the package.


1 Answers

The scope is at the session level. See the first sentence under the heading "Added Functionality" in the PL/SQL User's Guide and Reference

like image 107
DCookie Avatar answered Oct 01 '22 17:10

DCookie