Trigger to set trace on login
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Trigger to set trace on login

  1. #1
    Join Date
    Nov 2000
    Posts
    7
    I'd like to be able to set a trace on all sessions for a particular user. There may be sessions where the user connects, executes a few SQL statements and disconnects. How can I do this?

    I don't want to set the trace on in init.ora to capture all user session info. I can set tracing on for a current session by:
    ALTER SESSION SET SQL_TRACE=TRUE
    or by specifying the session id.
    But once the session closes/disconnects and the user later re-connects, I would need to reset the trace flag for the new session. There may be very many sessions.

    Can I create a trigger for After Logon that will set the flag just for that user?
    Can someone give me some help for how to do that?

    Thanks

  2. #2
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    342

    Arrow

    You can use

    sys.dbms_system.set_sql_trace_in_session(sid,serial#,true/false)

    sid and serial# can be found in v$session using

    select sid,serial#
    from v$session
    where audsid = userenv('sessionid');

    Hope this helps
    Gert



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width