27

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?

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
tpdi
  • 34,554
  • 11
  • 80
  • 120

2 Answers2

24

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

DCookie
  • 42,630
  • 11
  • 83
  • 92
  • 1
    You can change this behaviour by setting: PRAGMA SERIALLY_REUSABLE; – Rob van Laarhoven Mar 05 '10 at 10:30
  • 1
    You're not trying to say the globals are available across sessions, are you? Here is a description from the Oracle Application Developers Guide of PRAGMA_SERIALLY_REUSABLE: http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10795/adfns_pc.htm#1008314 – DCookie Mar 05 '10 at 15:37
  • 2
    Sorry, as usual, was not clear. It changes the scope of the package var from session to unit of work. Essentially disabling the reussability of the variable – Rob van Laarhoven Mar 08 '10 at 09:12
1

This variable can contain different values across multiple sessions. If you want to change this, please use PRAGMA_SERIALLY_REUSABLE.

Jeby Sebastian
  • 41
  • 1
  • 2
  • 7