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?
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.
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.
any variable defined outside of a procedure/function is a global variable and maintains its state for the duration of the session.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With