|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Getting sid in trigger
How to get SID, SERIAL# FROM V$SESSION in a trigger.
Anyprocedure or trigger using query select SID,SERIAL# from v$session gives error " Table or view does not exist". If query alone is executed it works fine. Being a synonym of sys , how v$session can be used in a procedure or trigger ? |
|
#2
|
|||
|
|||
|
I think, you dont have sufficient privileges to run that view, if the same query that your are using in the script is working fine on SQL prompt, it suppose to work in procedure also, however grant yourself DBA privileges or use SYS with your table like SYS.v$session. For your satisfaction see the following code:
CREATE OR REPLACE PROCEDURE get_session_info IS v_sid number; v_username varchar2(30); cur integer; CURSOR c_session IS SELECT sid,username FROM v$session; BEGIN DBMS_OUTPUT.ENABLE(1000000); cur := DBMS_SQL.OPEN_CURSOR; OPEN c_session; LOOP FETCH c_session INTO v_sid, v_username; EXIT WHEN c_session%NOTFOUND; DBMS_OUTPUT.PUT_LINE(v_sid||' '||v_username); END LOOP; DBMS_SQL.CLOSE_CURSOR(cur); END; / before run this code plz set your server output on, as follows: SQL>set serveroutput on now run this procedure: SQL>execute get_session_info; it will show you the data set on prompt. Regards, |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Getting sid in trigger |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|