dbms_output in Toad or SQL Plus [message #614528] |
Thu, 22 May 2014 16:28 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
azeem87
Messages: 116 Registered: September 2005 Location: dallas
|
Senior Member |
|
|
Hi,
i have read and implemented few suggestions from this site on dbms_output.. still when i run the below block.. i am not able to see any output.. in Toad, Sql developer and SQL Plus.. data is there i have taken the top select from this code and ran it runs successfully..
This code is to get the SQL last executed by session(SID) , before we plan to kil these SID we want see the code.
if there is other way to do that please suggest..
SET SERVEROUTPUT ON
set serveroutput on size 100000000
declare
x number;
begin
for x in
( select username||'('||sid||','||serial#||
') ospid = ' || process ||
' program = ' || program username,
to_char(LOGON_TIME,' Day DD YYYY HH24:MI') logon_time,
to_char(sysdate,' Day DD YYYY HH24:MI') current_time,
sql_address, LAST_CALL_ET
from gv$session
where status = 'INACTIVE'
and last_call_ET >1000
and MACHINE='HUB'
and username ='APPLICATION_USER'
-- and rawtohex(sql_address) <> '00'
and username is not null order by last_call_et )
loop
for y in ( select max(decode(piece,0,sql_text,null)) ||
max(decode(piece,1,sql_text,null)) ||
max(decode(piece,2,sql_text,null)) ||
max(decode(piece,3,sql_text,null))
sql_text
from gv$sqltext_with_newlines
where address = x.sql_address
and piece < 4)
loop
if ( y.sql_text not like '%listener.get_cmd%' )
--and y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%')
then
dbms_output.put_line( '--------------------' );
dbms_output.put_line( x.username );
dbms_output.put_line( x.logon_time || ' ' ||
x.current_time||
' last et = ' ||
x.LAST_CALL_ET);
dbms_output.put_line(
substr( y.sql_text, 1, 250 ) );
end if;
end loop;
end loop;
end;
Thanks
|
|
|
|
|
|
Re: dbms_output in Toad or SQL Plus [message #614915 is a reply to message #614544] |
Wed, 28 May 2014 11:55 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/61988.jpg) |
LKBrwn_DBA
Messages: 487 Registered: July 2003 Location: WPB, FL
|
Senior Member |
|
|
Littlefoot wrote on Fri, 23 May 2014 01:58Michel, he already did that (see top of code he posted).
In TOAD, you have to switch output ON. How? While in Editor, select "DBMS Output" tab, push the red button to turn it ON, optionally modify polling frequency and pay attention that polling button is also ON.
PS: In SQL Developer there is also a DBMS Output tab...
[Updated on: Wed, 28 May 2014 12:05] by Moderator Report message to a moderator
|
|
|
|
|