How can u create session variable in pakages?

Showing Answers 1 - 8 of 8 Answers

Sunaina

  • Sep 13th, 2006
 

By declaring a vaiable in package specification

  Was this answer useful?  Yes

rashid

  • Sep 20th, 2006
 

create or replace package pp

is

aa int :=00.00

end pp;

  Was this answer useful?  Yes

session variable can not be declared in package, variable declared in package are called global variables. 

create package mypack is

num number := 7;

num2 number;

end ;

here num, num2 are global variable

when ever you wnt to use them. you have to use mypack.num or mypack.num2

where as session variable are declared like:

variable res number;

now when ever in current session you wnt to use res , use :res

":" indicates the session variable

asraf_pa

  • Oct 10th, 2010
 

You can use DBMS_SESSION to set & get session variable. Below is the example for the same

SQL> EXEC DBMS_SESSION.SET_CONTEXT('CLIENTCONTEXT', 'myvar', 'myvalue');

PL
/SQL procedure successfully completed

SQL
> SELECT SYS_CONTEXT('CLIENTCONTEXT', 'myvar') FROM dual;

SYS_CONTEXT
('CLIENTCONTEXT','M')

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions