How to see the actual Oracle SQL statement that is being executed

后端 未结 6 1020
清歌不尽
清歌不尽 2021-01-31 03:53

I\'m using a custom-built inhouse application that generates a standard set of reports on a weekly basis. I have no access to the source code of the application, and everyone te

6条回答
  •  不知归路
    2021-01-31 04:46

    -- i use something like this, with concepts and some code stolen from asktom.
    -- suggestions for improvements are welcome

    WITH
    sess AS
    (
    SELECT *
    FROM V$SESSION
    WHERE USERNAME = USER
    ORDER BY SID
    )
    SELECT si.SID,
    si.LOCKWAIT,
    si.OSUSER,
    si.PROGRAM,
    si.LOGON_TIME,
    si.STATUS,
    (
    SELECT ROUND(USED_UBLK*8/1024,1)
    FROM V$TRANSACTION,
    sess
    WHERE sess.TADDR = V$TRANSACTION.ADDR
    AND sess.SID = si.SID

    ) rollback_remaining,

    (
    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)) ||
    MAX(DECODE(PIECE, 4,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 5,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 6,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 7,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 8,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 9,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 10,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 11,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 12,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 13,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 14,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 15,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 16,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 17,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 18,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 19,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 20,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 21,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 22,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 23,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 24,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 25,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 26,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 27,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 28,SQL_TEXT,NULL)) ||
    MAX(DECODE(PIECE, 29,SQL_TEXT,NULL)))
    FROM V$SQLTEXT_WITH_NEWLINES
    WHERE ADDRESS = SI.SQL_ADDRESS AND
    PIECE < 30
    ) SQL_TEXT
    FROM sess si;

提交回复
热议问题