Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQLTrace
To set on:
REM Script to turn TRACE MODE on for a selected SID.
set serveroutput ON size 2000;
set verify OFF;
DECLARE
r_sid NUMBER; v_sid NUMBER; v_serial NUMBER; v_username VARCHAR(30); v_status VARCHAR2(8); v_server VARCHAR2(9); p_server_pid VARCHAR2(9);
BEGIN
-- Accept r_sid Number 'What SID do you wish to trace? - '
r_sid := &SID;
SELECT s.sid, s.serial#, s.status, s.server, p.spid
INTO v_sid, v_serial, v_status, v_server, p_server_pid
FROM v$session s, v$process p
WHERE s.sid = r_sid
AND s.paddr = p.addr;
DBMS_OUTPUT.PUT_LINE ('Sid ' || TO_CHAR(v_sid) ||
' Serial# ' || TO_CHAR(v_serial) ||
' Username ' || v_username ||
' Status ' || v_status ||
' Server ' || v_server );
IF v_server != 'DEDICATED' THEN
DBMS_OUTPUT.PUT_LINE
('Tracing only produces valid results for a Dedicated Connection');
DBMS_OUTPUT.PUT_LINE
('Tracing *NOT* turned on.');
RETURN;
END IF;
-- Time to Turn Trace ON
SYS.DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(v_sid, v_serial, TRUE);
DBMS_OUTPUT.PUT_LINE ('Trace Mode is ON for '||v_sid); DBMS_OUTPUT.PUT_LINE ('Output sent to udump/ora_'||p_server_pid||'.trc');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('Cannot find a session for SID '||TO_CHAR(r_sid));
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Error: '||SQLERRM);
END;
/
To set off:
REM Script to turn TRACE MODE off for a selected SID.
set serveroutput ON size 2000;
set verify OFF;
DECLARE
r_sid NUMBER; v_sid NUMBER; v_serial NUMBER; v_username VARCHAR(30); v_status VARCHAR2(8); v_server VARCHAR2(9); p_server_pid VARCHAR2(9);
BEGIN
-- Accept r_sid Number 'What SID do you wish to trace? - '
r_sid := &SID;
SELECT s.sid, s.serial#, s.status, s.server, p.spid
INTO v_sid, v_serial, v_status, v_server, p_server_pid
FROM v$session s, v$process p
WHERE s.sid = r_sid
AND s.paddr = p.addr;
DBMS_OUTPUT.PUT_LINE ('Sid ' || TO_CHAR(v_sid) ||
' Serial# ' || TO_CHAR(v_serial) ||
' Username ' || v_username ||
' Status ' || v_status ||
' Server ' || v_server );
-- Time to Turn Trace OFF
SYS.DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(v_sid, v_serial, FALSE);
DBMS_OUTPUT.PUT_LINE ('Trace Mode is OFF for '||v_sid); DBMS_OUTPUT.PUT_LINE ('Output is in udump/ora_'||p_server_pid||'.ora');
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('Cannot find a session for SID '||TO_CHAR(r_sid));
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Error: '||SQLERRM);
END;
/
>>> mark_at_cool-tools.co.uk 04/23/01 12:55PM >>> Slightly off-topic:
Has anybody used the DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION procedure? If so what's the syntax etc. to use this?
Cheers
Mark
-----Original Message-----
Riyaj_Shamsudeen_at_i2.com
Sent: Monday, April 23, 2001 04:56
To: Multiple recipients of list ORACLE-L
You can also set _trace_files_public=TRUE in the init. ora file.This will
create trace files with 644 file permissions..
Thanks
Riyaj "Re-yas" Shamsudeen
Certified Oracle DBA
i2 technologies www.i2.com
"My opinions. Use at your risk"
"Koivu, Lisa" <lkoivu_at_qode. To: Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com> com> cc: Sent by: Subject: RE: SQLTrace root_at_fatcity. com 04/23/01 09:10 AM Please respond to ORACLE-L
Dave, you can also set a command in the cron to chmod the trace files frequently so everyone can access them.
Lisa Rutland Koivu
Oracle Database Administrator
Certified Self-Important Database Deity
Slayer of Unix Administrators
Wanton Kickboxing Goddess
lkoivu_at_qode.com
NeoMedia
2201 Second St., Suite 600
Fort Myers, FL 33901, USA
Phone: 941-337-3434
Fax: 941-337-3668
www.neom.com <http://www.neom.com> www.paperclick.com <http://www.paperclick.com> www.qode.com <http://www.qode.com>
P a p e r C l i c k . c o m <http://www.paperclick.com/home.htm>
Enter Your PaperClick Code Here!
-----Original Message-----
Sent: Monday, April 23, 2001 9:26 AM
To: Multiple recipients of list ORACLE-L
You can also set the user_dump_dest in init.ora to /tmp/oracle where all users have access.
>>> RROGERS_at_galottery.org 04/20/01 05:27PM >>> If I remember correctly the user can set autotrace on in the session and the output if sent to the terminal after the sql command is completed.
Give it a try.. You might have to set up permessions or privileges to get
it to work for a user.
ROR mª¿ªm
>>> turner_at_tellme.com 04/20/01 03:54PM >>> I've got a developer that says they need the unix password for oracle so they can do a trace and run tkprof without having to jump through a bunch of hoops. Anyone set up trace so someone other than oracle can do this?
The permissions on the trace files only allow reading by the file owner, so
setting the user into the dba group won't help.
Thanks, Dave Turner
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ And you thought James Bond's watch was cool... http://www.tellme.com Call 1-800-555-TELL for stocks, sports, news...& much more! -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: David Turner INET: turner_at_tellme.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Ron Rogers INET: RROGERS_at_galottery.org Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Gene Sais INET: Gsais_at_co.palm-beach.fl.us Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: Riyaj_Shamsudeen_at_i2.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Leith INET: mark_at_cool-tools.co.uk Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Tim Sawmiller INET: sawmillert_at_state.mi.us Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Mon Apr 23 2001 - 12:30:13 CDT
![]() |
![]() |