Enable SQL Tracing for Session

Hi,
I know how to enable SQL tracing for a session created either through SQL*Plus or like similar tool, but I want to explore is there any way to can we enable sql tracing for a single session which is connected to database through an application.
ssome time for testing purpose we have a requirement to enable tracing for that user which run batch Job. Now that particular user gets connected to database through application and i want to enable tracing right at that moment. How can I accomplish it.
Regards,
Ababsi

If you don't want to identify database session you can try to create a logon trigger to enable tracing for all database sessions created by a specific Oracle user account. In the following example you need to replace UWCLASS with the Oracle user account for which you want to trace sessions:
CREATE OR REPLACE TRIGGER trace_trig
AFTER LOGON
ON DATABASE
DECLARE
sqlstr VARCHAR2(200) := 'ALTER SESSION SET EVENTS ''10046 TRACE NAME CONTEXT FOREVER, LEVEL 12''';
BEGIN
  IF (USER = 'UWCLASS') THEN
    execute immediate sqlstr;
  END IF;
END trace_trig;
/Reference:
http://psoug.org/reference/system_trigger.html
If you want to identify database session you need to query V$SESSION to retrieve SID and SERIAL# of the session you want to trace and then you can use DBMS_MONITOR. See examples in http://www.oracle-base.com/articles/10g/SQLTrace10046TrcsessAndTkprof10g.php
Edited by: P. Forstmann on 15 janv. 2011 11:07

Similar Messages

  • Enabling SQL Tracing for already connected session

    Hi,
    I've a requirement. i.e. my users are connected to db through schema making sessions( As multiple users are connected from single Schema). Now there are certian users which have to run batch jobs and I want to trace there SQL for tunning. I want to know how can I enable SQL tracing for specific user,session,id since it is difficult to trace exact user as multiple users are running the batch jobs.
    I have a strategy to enable tracing at schema level. Can I do this while users are connected and running quries. As normally first we enable the tracing and then run the quries.
    Kindly help me in working out this.
    Regards,
    Abbasi

    You didn't post your Oracle version, but maybe you have DBMS_MONITOR available to you.
    Hope this helps!

  • Enabling SQL Tracing for an instance

    Hi,
    I am aware that SQL_TRACE init parameter is deprecated :
    Oracle® Database Upgrade Guide
    10g Release 2 (10.2)
    Part Number B14238-01
    Initialization Parameters Deprecated in Release 10.2
    SQL_TRACE
    So I searched the recommended way of enabling sql tracing for an instance and I found :
    Oracle® Database Performance Tuning Guide
    10g Release 2 (10.2)
    Part Number B14211-01
    20.4.2 Step 2: Enabling the SQL Trace Facility
    You can enable the SQL Trace facility for an instance by setting the value of the SQL_TRACE initialization parameter to TRUE in the initialization file.
    Well, the Tuning guide should not mention deprecated parameter, should it?
    Anyway, I found later that the recommended way is to use
    exec DBMS_MONITOR.DATABASE_TRACE_ENABLEPlease update your tuning guide.
    Cam on rat nieu ;-)

    Laurent,
    Sorry to post a reply after nearly 2 years :-)
    But:
    Does dbms_monitor.database_trace_enable() only trace existing sessions or does it also enable tracing for all new sessions?
    I've been consulting the documentation and searching on the Internet but I can't determine this.
    Cheers & thanks,
    Colin

  • SQL Tracing for session started from Java code

    I am working with Oracle 10g on Solaris 9. I am facing a problem when trying to enable SQL Trace for Oracle sessions initiated from Weblogic server. I am querring V$SESSION to get the SID and SERIAL# of those sessions and then using DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(<sid>, <serial#>, TRUE); from the SQLPlus (using sys login). But the trace file is not being generated in UDUMP even after some queries are fired from the application. But when I am using the same procedure to turn SQL Trace on for SQLPlus sessions or SQLDeveloper sessions, they are just working fine.
    Can anyone please help me out?

    Please help.....
    There is already a thread
    Problem with SQL_Trace for a Session
    but there is no solution there.

  • Enabling SQL tracing from Forms

    Hi...
    can I enable SQL tracing for Particular instance or session from my 6i/9i forms.I can do it directly from database but what if i want to do it from Forms programatically or forms provides something which can help me ....
    any idea ???
    Thanx in advance

    REPOST

  • Automize SQL TRACE for a selected session

    Hi,
    Should I automize the process of SQL Tracing for a particular session of our choice?
    Let’s say when there are several sessions, and we want to select the particular session for SQL TRACING, then the SQL tracing for that session enable via running a routine.
    I used AFTER LOGON trigger for enabling SQL trace, but using this approach enable SQL TRACING all the sessions.
    My Logon Trigger for enabling SQL Tracing:
    create or replace trigger LOGON_SQL_TRACE
    after logon on database
    begin
    execute immediate
    'alter session set sql_trace=true';
    end;
    I want to use a perfect routine that first get the sid, serial# or username etc. from V$session, V$process or else, and then enable the SQL TRACING for the selected session.
    Like SYS.DBMS.SYSTEM.SET_SQL_TRACE_IN_SESSION package is available for doing that or may be some others as well.
    But how should we use these packages or other SQL tracing commands in a routine, which we can use for, enable SQL Tracing implicitly.
    Any ideas will be great.
    Bill

    SYS.DBMS.SYSTEM.SET_SQL_TRACE_IN_SESSION is just fine.
    You can get the SID and SERIAL# from v$session; you just have to know the username, osmachine, the OS process, ...
    Fred

  • SQL TRACE FOR THIRD PART TOOL

    Hi,
    Should we use the Logon trigger for SQL TRACING,for the third party tool?
    How should we manage SQL tracing and then read this trace file using
    TKPROF for that specific session that is using the third party tool?
    I wanted that whenever this third party tool connect to database with any user, the sql tracing will start for that specific seesion and then read the sqltrace for that session using TKPROF.
    Any ideas/exmp will be great.
    Regards
    CLEE

    Should we use the Logon trigger for SQL TRACING,for the third party tool?
    Yes you can use like
    CREATE OR REPLACE TRIGGER af_sess_Logon
    After logon on database
    Begin
    if ( user='SCOTT') then
    execute immediate 'alter session set sql_trace=true';
    End if;
    End;
    sql tracing will start for that specific seesion and then read the sqltrace for that session using TKPROF.
    for tkprof you can user command line
    or use host in sql
    kuljeet pal singh

  • SQL Trace for ODS Scripts

    Hi,
    How can I turn on SQL Tracing for ODS Transfer scripts?
    Best regards,
    Johan

    Hi Johan,
    If SAP Note 1289112 is not the case, please clarify what "ODS Transfer" means.
    Regards,
    Sergiy

  • Setting SQL TRACING

    Hi ,
    I want to set Sql tracing on in my machine.
    I am using the oracle 9i Database (9.2.0.4.0).
    My operating system is windows 2000 professional.
    Can anyone tell me how to enable SQL tracing in my database and wat is the use of it.
    Thanks...

    http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#8760

  • SQL Logging for a specific session or table

    Hi!
    Don't know if this is the right place to ask, so sorry if it's wrong.
    Is there any possibility to log all SQL activity which a specific session id is producing.
    Using the Instance Manager I can only see the Latest SQL statement but no history.
    Please help my poor soul...
    Thanks in advance
    Greets, Hansi

    Hi Joel and everyone,
    Thanks for your information.
    But I like to say that, I wanted to store the text of these SQL TRACE files which belongs to different session, into my table SQL_TRACE (session_id, username, text).
    As you said that we can use DBMS_SESSION.SET_SQL_TRACE (sql_trace True);
    to enable the tracing of particular session.
    I know TKPROF is the utility via which we can read these sql trace files.
    For Example:
    C:\ tkprof c:\SQL_TRACE\ora012929.trc c:\SQL_text\oratext.txt
    With regards to this, how should we read the trace files for the users who logon to the database using the feature of logon trigger and then store the text of these sqltrace files of different users into the table SQL_TRACE (session_id, username, text).
    I wanted to use my table for getting sqltrace info for Historical purpose.
    It is my requirement.
    Could you please give your suggestion about it?
    Thanks
    Jaffery.

  • How to enable remote debugging for a session other than the current one

    Hi all,
    I am trying to figure out how to enable remote debugging for a session other than the one I am currently using.
    More specifically, we have an application that is making database calls to Oracle 11gR2. Something is causing an exception during this invocation. My system is currently not set up to recompile said application, so I can't just add the debug call to the code and recompile. Therefore I would like to be able to log into the database (as sys, if necessary) and invoke dbms_debug_jdwp.connect_tcp on the desired session.
    The docs indicate that I should be able to do so:
    dbms_debug_jdwp.connect_tcp(
    host IN VARCHAR2,
    port IN VARCHAR2,
    session_id IN PLS_INTEGER := NULL,
    session_serial IN PLS_INTEGER := NULL,
    debug_role IN VARCHAR2 := NULL,
    debug_role_pwd IN VARCHAR2 := NULL,
    option_flags IN PLS_INTEGER := 0,
    extensions_cmd_set IN PLS_INTEGER := 128);
    But when I try (even as sys), I get the following:
    exec dbms_debug_jdwp.connect_tcp('1.2.3.4',5678,<session id>,<session serial>);ORA-00022: invalid session ID; access denied
    ORA-06512: at "SYS.DBMS_DEBUG_JDWP", line 68
    ORA-06512: at line 1
    00022. 00000 - "invalid session ID; access denied"
    *Cause:    Either the session specified does not exist or the caller
    does not have the privilege to access it.
    *Action:   Specify a valid session ID that you have privilege to access,
    that is either you own it or you have the CHANGE_USER privilege.
    I've tried granting the 'BECOME USER' privilege for the relevant users, but that didn't help. I read something about having to set some kind of ACL as of 11gR1, but the reference documentation was very confusing.
    Would someone be able to point me in the right direction? Is this even possible, or did I misread the documentation?

    Interesting deduction, that would be very useful indeed. I hate recompiling just to add the debug call, and it can't be done in our production environment. But it seems unlikely to me it would be implemented this way.
    I would cross-post this in the SQL AND PL/SQL forum though, as this is really a database issue, not with the SQL Developer tool. Do add the links to the other posts in each.
    Regards,
    K.

  • Enable SQL Notification Services for BAM alerts , Biztalk 2010

    Hi,
    Enable SQL Notification Services for BAM alerts is greyed out.
    I need to enable bam alerts in BizTalk 2010.
    Regards,
    Sharmishtha

    Hi,
    If I understand correct, your problem is that the BAM Alerts configuration is greyed out in the BizTalk Configuration tool. If this is the problem it's due probably because you don't have the SQL Server 2005 Notification Services installed. Notification
    Services is required for BAM Alerts feature.
    You can take a look at the following link, even it's for multi-computer installation:
    http://social.technet.microsoft.com/wiki/contents/articles/1888.install-and-configure-bam-business-activity-monitoring-in-a-multi-computer-environment.aspx
    Best regards.

  • SQL tracing in ADR

    Hi,
    I've a question and needs calrification. As in 11g $ADR_HOME/trace holds the information of background process tracing and SQL tracing. Now I want to know how can we seperate the SQL tracing files and BG tracing files. Let say its not possible and both are written in single trace files, then my question is can we extract SQL tracing information from this single file through tkprof.
    I'm not sure weather BG tracing is enabled by default or not. Please clarify it as we have to explicityly enabled the SQL tracing.
    Looking for your information.
    Regards,
    Abbasi

    I think that it would be hard to tell which file belongs to the background process or which one to the foreground process just by looking at the files. We must know the process id and then use it to track the file. The trace folder contains both the Background and User_Dump_Dest combined in it so it contains both the files. Background tracing is not on( I think that there is no such concept called background tracing) and the trace file would be generated when the process would be abruptly terminated.
    Just my 2 cents.
    Aman....

  • SQL Tracing

    Hi,
    in 8.49 tools version,
    It's a part of psappsrv.cfg file :
    [Trace]
    ;=========================================================================
    ; Server Trace settings
    ;=========================================================================
    ; SQL Tracing Bitfield
    ; Bit Type of tracing
    ; 1 - SQL statements
    ; 2 - SQL statement variables
    ; 4 - SQL connect, disconnect, commit and rollback
    ; 8 - Row Fetch (indicates that it occurred, not data)
    ; 16 - All other API calls except ssb
    ; 32 - Set Select Buffers (identifies the attributes of columns
    ; to be selected).
    ; 64 - Database API specific calls
    ; 128 - COBOL statement timings
    ; 256 - Sybase Bind information
    ; 512 - Sybase Fetch information
    ; 1024 - SQL Informational Trace
    ; 4096 - Manager information
    ; 8192 - Mapcore information
    ; Dynamic change allowed for TraceSql and TraceSqlMask
    TraceSql=?
    TraceSqlMask=?
    which values should be given for TraceSql=? and TraceSqlMask=? to enable the followings :
    - SQL statements
    - SQL statement variables
    - SQL connect, disconnect, commit and rollback
    - Row Fetch (indicates that it occurred, not data)
    If you suggest a value please explain how/why you have chosen it.
    Many thanks.

    Thank you Nicolas.
    Why there is also something similar in PSPRCS.cfg :
    Trace settings
    ;=========================================================================
    ; PeopleTools trace file (NT only, ignored on UNIX)
    TraceFile=%PS_SERVDIR%\logs\PeopleTools.trc
    ; SQL Tracing Bitfield
    ; Bit Type of tracing
    ; 1 - SQL statements
    ; 2 - SQL statement variables
    ; 4 - SQL connect, disconnect, commit and rollback
    ; 8 - Row Fetch (indicates that it occurred, not data)
    ; 16 - All other API calls except ssb
    ; 32 - Set Select Buffers (identifies the attributes of columns
    ; to be selected).
    ; 64 - Database API specific calls
    ; 128 - COBOL statement timings
    ; 256 - Sybase Bind information
    ; 512 - Sybase Fetch information
    ; 1024 - SQL Informational Trace
    ; Dynamic change allowed for TraceSql and TraceSqlMask
    TraceSQL=0
    What is the difference ?
    Thanks again.

  • Looking for SQL*Net for Windows 95

    I have Brio client installed on my laptop running Windows 98. I am looking for SQL *Net for Windows 95, to connect to an Oracle database running on Solaris.  Where can I find it.
    How do I connect? I tried MS ODBC and it did not work.
    Please help
    My email address is [email protected]
    Thanks in advance

    despite that I do not know the type of the Firewall , I was able to adjust Oracle with Microsoft ISA server as follows :
    go to oracle server on Windows 2000
    open system variables
    insert the following variable : USE_SHARED_SOCKET
    make its value : TRUE
    restart server
    this variable will make you able to share ports on windows platform ,, this is essential because Oracle servers replies back on any port randomly when trying to connect to it ,, you can track this by enabling tracing for listener.
    on firewall you will need to redirect connection received by the firewall on specific port on the firewall and NAT it to Oracle server IP/port .
    this is proven work
    on UNIX you do not need this beacsue Unix natively share ports.

Maybe you are looking for

  • Since installing Nuance PDF Converter Professional, PDFs are opened by Nuance instead of Acrobat, which is also installed. I want Acrobat to be the default.

    I have been a longtime user of Firefox and Adobe Acrobat (NOT the reader). A few months ago I installed Nuance PDF Converter, and stipulated that Acrobat should be the default when opening PDFs. However, when the PDF is opened under Firefox, Nuance i

  • Setting Google Maps as default Map program

    I am using Torch 9810 Ssw V7.0.0 build 2404 on ATT.  I have installed Google Maps and it seems to be working fine.  Of course the Torch also came with ATT Maps and Blackberry Maps.  How to I set up Google Maps as the default map program so that when

  • How to test File Adapter from EM Console

    Hi All, I have one issue with File Adapter where I am trying to implement a simple BPEL process. Below are the steps; 1. I have created an empty BPEL process and then add a read file adapter to the left side which will read from a file aa.txt which i

  • Authorization error in Repository after idle time

    Hi all, I have a problem in ESR where after some idle time I suddenly loose all my authorizations to perform any actions in Repository (sometimes also Directory). I'm even denied the authorization to close objects or the entire ESR altogether. This h

  • Popup Error on Start up

    Everytime I start my computer I get a window notification that says "Failed to listen for incoming Popup Job. You will not be able to use Popup printing for the duration of this session. Please report this incident to a system administrator." I've fo