Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Extracting SQL_TEXT from v$SQLAREA

Re: Extracting SQL_TEXT from v$SQLAREA

From: Dave Haas <davehaas_at_hotmail.com>
Date: Thu, 21 Dec 2000 17:38:14 -0700
Message-ID: <91u81h$7p9$1@news3.cadvision.com>

Neo.

Have a look at LogMiner. It'll be WAY easier.

Regards,

Dave Haas

"NEO" <sneo_at_my-deja.com> wrote in message news:91tsp9$rfp$1_at_nnrp1.deja.com...
> I am auditing SELECT statements on a particular table (say MyTable). I
> need to extract the SQL statement issued during the SELECT. Since, the
> AUD$ table does not store the SQL statement, I tried the following
> apporach:
>
> 1. Change AUD$ ownership to SYSTEM and grant SYS all privileges for the
> table.
> 2. Attach a AFTER INSERT trigger to the AUD$ table to extract the SQL
> statement issued by the user.
>
> CREATE OR REPLACE ...
> AFTER INSERT ON SYSTEM.AUD$
> ...
> BEGIN
> INSERT INTO SOMETABLE
> SELECT B.SQL_TEXT
> FROM V$SESSION A, V$SQLAREA B
> WHERE (A.SQL_HASH_VALUE = B.HASH_VALUE)
> AND (A.SQL_ADDRESS = B.ADDRESS)
> AND ( A.AUDSID = :NEW.SESSIONID);
> END;
>
>
> The trigger works but does not grab the SELECT statement issued by the
> user. Instead, it grabs the INSERT statement that I am issuing in the
> trigger ("INSERT INTO SOMETABLE ... ") from v$SQLAREA.
>
> When I issue "SELECT B.SQL_TEXT FROM V$SESSIOn A, ... AND (A.AUDSID =
> ###)" directly in SQL*Plus, I get the correct SELECT statement I am
> looking for.
>
> I assume my trigger is grabing the currently executing SQL statement.
> Is there a way for me to grab the SQL statement that caused the insert
> into the AUD$ table such as: "Select count(*) from MyTable" ?
>
> Thanks.
>
>
> Sent via Deja.com
> http://www.deja.com/
Received on Thu Dec 21 2000 - 18:38:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US