set heading off;
set echo off;
/* ****************************************************** */
/*                                                        */
/* Name:    sstmt2.sql                                    */
/* Purpose: SQL statement activity                        */
/* Creator: R.Kupcunas                                    */
/* Date:    01-Jan-98                                     */
/*                                                        */
/* Run: @C:\rkupcuna05_ora\Oracle\SQL\sstmt2.sql          */
/*                                                        */
/* ****************************************************** */

set echo off;
spool sstmt2.rslt;

select to_char(sysdate, 'YY-MON-DD HH:MI:SS am') from dual;

col hv          noprint
col ln          heading 'Line'                  format        9,999
col ss          heading 'SQL Statement'         format          A65

/* ************************* */
/* extract the SQL statement */
/* ************************* */

select  b.hash_value                    hv,
        b.piece                         ln,
        b.sql_text                      ss
from    v$sqlarea a,
        v$sqltext b
where   a.address = b.address
  and   a.hash_value = b.hash_value
  and   trunc(a.hash_value/99999) = &&statement_id
order by 1,2;

undefine statement_id;

spool off;
set heading on;
set echo on;

commit;
