Automize SQL TRACE for a selected session
Hi,
Should I automize the process of SQL Tracing for a particular session of our choice?
Lets 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
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,
AbbasiYou didn't post your Oracle version, but maybe you have DBMS_MONITOR available to you.
Hope this helps! -
No insert Statements for EKKO EKPO in ST05 sql trace for transaction me21n
No insert Statements for EKKO EKPO in ST05 sql trace for transaction me21n.
IN ST05 I set a filter for ME21N and executed transaction to create a Purchase Order and then checked
ST05 but there is NO insert for EKKO or EKPO??
How Do I find in which columns of EKKO and EKPO data is inserted in ST05?
Edited by: DeepakNandikanti on Apr 28, 2010 8:27 AMHi,
I tried in my system and I can see INSERT statement on EKKO and EKPO tables. What exactly you are looking for? Some one else might have switched on the trace at the same time. Can you try again and see.
ST05=>Switch on trace
ME21N=>Create PO.
ST05=>Switch off and display trace.
In trace list search for EKKO and EKPO.
Column names are not shown in the trace list. It is the SQL trace and column list is generated dynamically like :A0, :A1....
@ Suhas,
That might be because the tables are updated via BAPIs ... Do you think SAP uses direct update statements on the DB tables ??
I didn't get above statement. Is there any other way of updation that happens when using BAPI? I believe that, even in case of BAPI there will be update task FMs called during database update. Please correct if i got it wrong.
Thanks,
Vinod. -
Hi
Can anyone suggest how to find the SQL trace for background jobs.
Thanks in advance.
Regards
D.VadivukkarasiHi
Check the transaction ST05.
Plz Reward Points if helpful -
Hi
Database 10.1.0.4
Sql trace file which I have used but didn't get the trace file. I have tried to get per session Id but not able to get the trace file, when ever user logged into application, virtually 6 user get lgged in and you never know about user. So I have desided to capture for schema
I have used this for tracing
SQL> ALTER SESSION SET sql_trace=TRUE;
SQL> ALTER SESSION SET sql_trace=FALSE;
Or
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => TRUE);
SQL> EXEC DBMS_SESSION.set_sql_trace(sql_trace => FALSE);
or
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>TRUE);
SQL> EXEC DBMS_SYSTEM.set_sql_trace_in_session(sid=>123, serial#=>1234, sql_trace=>FALSE);
I want to get trace file for schema, can anyone suggest how do I get trace file at schema level.
Thanks for helpHi,
Using instance-level tracing by setting the init.ora/spfile... parameter SQL_TRACE=TRUE, all processes against the instance will create their own trace files. This particular method of tracing should be used with care since it creates a great deal of overhead against the system. In addition, the default value for this parameter is FALSE.
Cheers
Legatti -
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
CLEEShould 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 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, HansiHi 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. -
Problem writing a sql query for a select list based on a static LOV
Hi,
I have the following table...
VALIDATIONS
ID Number (PK)
APP_ID Number
REQUESTED Date
APPROVED Date
VALID_TIL Date
DEPT_ID Number (FK)
I have a search form with the following field item variables...
P11_DEPT_ID (select list based on dynamic LOV from depts table)
P11_VALID (select list based on static Yes/No LOV)
A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
SELECT v.APP_ID,
v.REQUESTED,
v.APPROVED,
v.VALID_TIL,
d.DEPT
FROM DEPTS d, VALIDATIONS v
WHERE d.DEPT_ID = v.DEPT_ID(+)
AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
Can anyone help me to extend my query to include this situation?
Thanks.Hello !
Let's have a look at my example:create table test
id number
,valid_til date
insert into test values( 1, sysdate-3 );
insert into test values( 2, sysdate-2 );
insert into test values( 3, sysdate-1 );
insert into test values( 4, sysdate );
insert into test values( 5, sysdate+1 );
insert into test values( 6, sysdate+2 );
commit;
select * from test;
def til=yes
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
def til=no
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
drop table test; It's working fine, I've tested it.
The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
For understandings:
1.) TRUNC removes the time part of DATE
2.) The difference of to date-values is the number of days between.
3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
4.) DECODE is like an IF.
Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
Good luck,
Heinz -
SQL TRACE for WEB deployed report
When I put
Alter Session Set sql_trace=TRUE
into the BEFORE Parameter Form trigger...
I get a trace file showing data on the one SQL in that trigger.
There is no TRACE output of the main query or any of the PL/SQL in the Program Units.
The report is invoked from company-wide intra-net.
I think it is Oracle Apps running in Linux server.
What am I doing wrong?
PS
I cannot execute this report from Report Builder.Hello,
Just a remark : if you are using Reports 9.0.4 / 10.1.2, you don't have to modify the reports , you can activate the SQL trace with the parameter SQLTRACE=YES
http://www.oracle.com/webapps/online-help/reports/10.1.2/topics/htmlhelp_rwbuild_hs/rwrefex/cmdline/common/cla_sqltrace.htm
Regards -
Need to wite pl sql procedure for dynamic select statement
Need pl sql procedure for a Dynamic select statement which will drop tables older than 45 days
select 'Drop table'||' ' ||STG_TBL_NAME||'_DTL_STG;' from IG_SESSION_LOG where substr(DTTM_STAMP, 1, 9) < current_date - 45 and INTF_STATUS=0 order by DTTM_STAMP desc;I used this to subtract any data older than 2 years, adjustments can be made so that it fits for forty five days, you can see how I changed it from the originaln dd-mon-yyyy to a "monyy", this way it doesn't become confused with the Static data in the in Oracle, and call back to the previous year when unnecessary:
TO_NUMBER(TO_CHAR(A.MV_DATE,'YYMM')) >= TO_NUMBER(TO_CHAR(SYSDATE - 365, 'YYMM')) -
Hi,
How can I turn on SQL Tracing for ODS Transfer scripts?
Best regards,
JohanHi Johan,
If SAP Note 1289112 is not the case, please clarify what "ODS Transfer" means.
Regards,
Sergiy -
Q1.How can you trace the session of forms?
c:\ifrun60 module=<formname> userid=scott/tiger
statistics=yes
This will do a alter session set sql_trace=true in the background. -
How to trace for multiple user sessions?
Hello -
I have a username from the app that has 7 connections to the database. What is the easiest way that I can run the 10046 trace event across all 7 sessions, and also name the trace files so they can be recognized in user_dump?
Thanks in advance!Check what sid and serial# has session:
select sid, serial# from sys.v_$session where ...
start tracing session with:
execute dbms_system.set_sql_trace_in_session(sid, serial#, true);
stop tracing with
execute dbms_system.set_sql_trace_in_session(sid, serial#, false);
Look into udump directory for trace files:
The default name for a trace files is INSTANCE_PID_ora_TRACEID.trc where:
INSTANCE is the name of the Oracle instance,
PID is the operating system process ID (V$PROCESS.OSPID); and
TRACEID is a character string of your choosing. -
Hi,
i was tracing the sql statments present in vf03 transaction for the invoice no.'s with accounting document over all status as not clear.
i want to know the flow of the sql statements right from the user giving the invoice no. as input to the document flow window to know from where and how it is picking the accounting doucment over all processing status
waiting for ur replies
regards,
maqsoodHi
You should look at the code of std fm RV_ORDER_FLOW_INFORMATION, here you can see all selects the system does.
Anyway the tables are VBFA (document flow), VBUK and VBUP. But you can't find that information here, because it's only in accounting not in sales.
So perhaps the abap code you're looking for it's this:
if vbrk-vbeln <> vbfa_tab-vbeln.
perform vbrk_ermitteln using vbfa_tab-vbeln.
check sy-subrc = 0.
check xvbrk-rfbsk = 'C' or xvbrk-rfbsk = 'J'.
read table xdoc_num with key vbeln = vbfa_tab-vbeln
binary search.
tabix_xdoc = sy-tabix.
if sy-subrc = 0.
check xdoc_num-not_found is initial.
else.
refresh xbkpf.
call function 'FI_DOCUMENT_READ'
exporting
i_awtyp = 'VBRK'
i_awref = vbfa_tab-vbeln
i_awsys = vbrk-logsys
i_bukrs = vbrk-bukrs
i_gjahr = vbrk-gjahr
tables
t_bkpf = xbkpf
t_bseg = xbseg
exceptions
wrong_input = 1
not_found = 2.
describe table xbkpf lines sy-tabix.
if sy-tabix ne 0.
Delete documents from other fiscal year
if sy-tabix > 1.
CALL FUNCTION 'FI_PERIOD_DETERMINE'
EXPORTING
i_budat = vbrk-fkdat
i_bukrs = vbrk-bukrs
IMPORTING
e_gjahr = da_gjahr
e_poper = da_poper
EXCEPTIONS
fiscal_year = 1
period = 2
period_version = 3
posting_period = 4
special_period = 5
version = 6
posting_date = 7
OTHERS = 8.
IF sy-subrc = 0.
CONCATENATE da_gjahr da_poper INTO vbrk-gjahr.
loop at xbkpf where gjahr ne vbrk-gjahr.
delete xbkpf index sy-tabix.
endloop.
ENDIF.
endif.
loop at xbkpf.
clear l_xdoc_num-status.
move 'BKPF' to l_xdoc_num-awtyp.
move xbkpf-bukrs to l_xdoc_num-bukrs.
move xbkpf-belnr to l_xdoc_num-docnr.
move xbkpf-cpudt to l_xdoc_num-cpudt.
move xbkpf-gjahr to l_xdoc_num-gjahr.
l_xdoc_num-vbeln = vbfa_tab-vbeln.
l_xdoc_num-logsys = vbrk-logsys.
clear l_xdoc_num-not_found.
loop at xbseg where bukrs eq xbkpf-bukrs
and belnr eq xbkpf-belnr
and gjahr eq xbkpf-gjahr
and ( koart eq 'D' or koart eq 'K' ).
endloop.
if sy-subrc ne 0.
l_xdoc_num-status = 'C'.
else.
loop at xbseg where not augbl is initial
and ( koart eq 'D' or koart eq 'K' ).
endloop.
if not sy-subrc is initial.
SET STATUS TO 'No items are cleared'
l_xdoc_num-status = 'A'.
else.
loop at xbseg where augbl is initial
and umskz ne 'A'
and vorgn ne 'AZUM'
and ( koart eq 'D' or koart eq 'K' ).
endloop.
if not sy-subrc is initial.
Set status to 'All items are cleared'
l_xdoc_num-status = 'C'.
endif.
endif.
Otherwise: If there are customer/vendor positions where AUGBL is
filled and some other ones where AUGBL is blank then set status
to 'Partially cleared'
if l_xdoc_num-status is initial.
l_xdoc_num-status = 'B'.
endif.
endif.
append l_xdoc_num.
endloop.
insert lines of l_xdoc_num into xdoc_num index tabix_xdoc.
This is extracted from include LV05CF01
Max -
How to set SQL trace in OCI session ?
Hello,
In a SQL*Plus session, I can use the SQL statement "alter session set sql_trace=true;" to set SQL trace in that session only. I assume I could execute the same SQL statement from C code in an OCI client and achieve the same goal.
However, if I cannot change the code of this OCI client, is there a way to set SQL trace for that single session alone, without changing the C code? Say, through an environment variable, configuration file, etc.?
Thanks.I am not aware of a way to selectively enable the server-side tracing without modifying the client code.
There is client tracing available by setting the environment variable EVENT_10842 as follows:
"server=<>;user=<>;stmt=<>;level=<>;interval=<>"
e.g.
setenv EVENT_10842 "server=inst1,inst2;user=scott,system;stmt=all;level=15"
Where:
"server" is a comma separated list or "all"
"user" is a comma separated list or "all"
"stmt" can be INSERT,UPDATE,DELETE,SELECT or "all"
The following levels are supported:
1 - Trace all server attach and server detach calls for servers listed in "server" attribute of the environment variable.
2 - Trace all session begin, logon, session end, logoff calls for the users listed in "user" attribute of the environment variable.
3 - Trace all prepare, execute, fetch calls for the specified statement types listed in "stmt" attribute of environment variable.
4 - Trace all Bind, Define, Describe calls.
5 - Trace all OCI LOB calls
7 - Get statistical info on all connection pooling /connection related calls
8 - Get statistical info on all session info
9 - Get statistical info on all handle info
10 - Get statistical info on time taken in execute and fetch calls
11 - Get statistical info on transaction related calls
15 - Trace all calls with statistical info.
Maybe you are looking for
-
Hi I have an Imac I5 21.5 inch.It was working perfectly.Then i didnt use that for about 2 months. Week ago when i want to start the Imac ,it didnt start. When press and hold or keep on pressing the power button then i hear the fans are working and i
-
Hi, I created a theme using NWDS theme plugin.The path that i need to paste the theme is Drive:\usr\sap\Instance\JC00\j2ee\cluster\server0\temp\webdynpro\web\sap.com\tcwddispwda\global\SSR\themes. The problem is if i have 6 server nodes i need to pla
-
How to secure webservice in weblogic server?
Hi, How many ways to secure a webservice in weblogic server? and what is the purpose of SSL ?
-
Flickering Desktop Background Yosemite
Hello! I have a 15" MacBook Pro early 2011, recently upgraded OS X to Yosemite 10.10.1, Specs: Processor: 2 GHz Intel Core i7; Memory: 4 GB 1333 MHz DDR3; Graphics: Intel HD Graphics 3000 384 MB. I was working with Word and suddenly the keyboard stop
-
We have a process in which we are doing subcontracting for our customer. Our external customer will send the material to us on 57f4/Excise paid subcontracting challan. We will process the material and send it back to the customer. How can we map this