根據程式的ID取得該程式的SQL指令碼

orchidllh發表於2004-12-09

根據程式的ID取得該程式的SQL指令碼、根據程式的ID取得該程式對應的session情況、跟蹤指定程式及取消跟蹤


-------------根據程式的ID取得該程式的SQL指令碼
SELECT   /*+ ORDERED */
         sql_text
    FROM v$sqltext a
   WHERE (a.hash_value, a.address) IN (
            SELECT DECODE (sql_hash_value,
                           0, prev_hash_value,
                           sql_hash_value
                          ),
                   DECODE (sql_hash_value, 0, prev_sql_addr, sql_address)
              FROM v$session b
             WHERE b.paddr = (SELECT addr
                                FROM v$process c
                               WHERE c.spid = '&pid'))
ORDER BY piece ASC;


------------根據程式的ID取得該程式對應的session情況
SELECT SID, SERIAL#, USERNAME, MACHINE
FROM V$SESSION B
WHERE b.paddr = (SELECT addr
  FROM v$process c
  WHERE c.spid = '&pid');

-----跟蹤指定程式
exec dbms_system.set_sql_trace_in_session(247,3918,true);

----取消跟蹤
exec dbms_system.set_sql_trace_in_session(239,4215,false);

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/51862/viewspace-180574/,如需轉載,請註明出處,否則將追究法律責任。

相關文章