-- gss.sql: current SQL text and identity for one session on RAC -- Copyright (c) HASHJOIN. MIT License (https://hashjoin.com/kb/license/) -- https://hashjoin.com/kb/oracle/drill-into-one-session/ -- -- Usage: @gss.sql -- @gss.sql 2 1234 clear col clear breaks set lines 80 set trims on set pages 9000 col sql_text format a70 word_wrapped col inst_id format a10 noprint new_value n_inst_id col sid format a10 noprint new_value n_sid col serial format a10 noprint new_value n_serial col username format a20 noprint new_value n_username col machine format a20 noprint new_value n_machine col osuser format a20 noprint new_value n_osuser col process format a20 noprint new_value n_process col action format a45 noprint new_value n_action break on sid on serial on username on process on machine on action skip page ttitle - "Instance...... : " n_inst_id - skip 1 - "Sid .......... : " n_sid - skip 1 - "Serial ....... : " n_serial - skip 1 - "Username ..... : " n_username - skip 1 - "Machine ...... : " n_machine - skip 1 - "OSuser ....... : " n_osuser - skip 1 - "Process ...... : " n_process - skip 1 - "Action ....... : " n_action - select /*+ ORDERED */ ses.inst_id,sid,serial# serial,username,machine,osuser,process,module||' '||action action,sql_text from gv$session ses, gv$sqltext_with_newlines txt where txt.address(+) = ses.sql_address and txt.hash_value(+) = ses.sql_hash_value and txt.inst_id = ses.inst_id and ses.inst_id = &&1 and ses.sid = &&2 order by inst_id,sid,piece;