Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 12th, 2004, 05:45 AM
tarun chandani tarun chandani is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 tarun chandani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 ?

Reply With Quote
  #2  
Old March 26th, 2004, 08:33 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 6
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,

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Getting sid in trigger


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT