tags:

views:

24

answers:

1

Hi,

How can global variables be use thread safe in oracle? My scenario is simultaneous user can access a oracle package/procedure which contain global variable, I need to have separate copy of global variable values for each user. Each user belongs to different java session which intern invokes this db package

Does oracle spawn threads with in a oracle session. Can these threads assigning values to global variables change values to other user's threads?

please suggest

+6  A: 

Your problem doesn't exist. Global package variables aren't truely global. Each session has it's own variable (i.e. each user and, if the user logs in several times, he/she has separate values in each session).

And you cannot spawn threads yourself. In particular on Unix, Oracle doesn't use threads as far as I can tell.

If you want to use truely global variables, have a look a CONTEXT objects.

Codo
+1 but I think there's a bit of confusion here over what "global" means - there may be other definitions, but in PL/SQL they are global in scope (i.e. they can be referenced anywhere in the package) but not in duration (i.e. they cannot be referenced outside the session).
Jeffrey Kemp