Fatcodeguy,
(Do you have nickname that you answer to? Calling you "Fat" just seems a bit...I dunno...)
Okay, to your questions. There are two ways to create a "persistent" session variable that you can access throughout your session. One way is with a bind variable, the other is with a global PL/SQL variable. Once you create them, you access them pretty much the same way.
Method 1 -- Bind variable:
Code:
SQL> var x number
SQL> exec :x := 150
PL/SQL procedure successfully completed.
SQL> exec :x := :x + 1
PL/SQL procedure successfully completed.
SQL> select :x from dual;
:X
----------
151
1 row selected.
Method 2 -- PL/SQL Global variable:
Code:
SQL> create or replace package vars
2 is
3 x number;
4 function getx return number;
5 end;
6 /
Package created.
SQL> create or replace package body vars is
2 function getx return number is
3 begin return x;
4 end;
5 end;
6 /
Package body created.
SQL> select vars.getx from dual;
GETX
----------
1 row selected.
SQL> exec vars.x := 150;
PL/SQL procedure successfully completed.
SQL> exec vars.x := vars.x + 1;
PL/SQL procedure successfully completed.
SQL> select vars.getx from dual;
GETX
----------
151
1 row selected.
Now,
Fatcodeguy said:
"how do I invalidate a session, like a pseudo-logout?"
Method 1 -- Just "disconnect" from SQL*Plus (You will, however, need to re-connect as someone before you can access the database.)
Code:
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL>
Method 2 -- Just "re-connect" as yourself. (Clean and simple.):
Code:
SQL> connect test/test
Connected.
SQL>
Let us know if these suggestions resolve your needs.
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA)
@ 17:28 (26Nov04) UTC (aka "GMT" and "Zulu"),
@ 10:28 (26Nov04) Mountain Time