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: How to get the current/last run SQL statement into a string variable?

Re: How to get the current/last run SQL statement into a string variable?

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 06 Apr 2007 08:57:41 -0700
Message-ID: <1175875057.144643@bubbleator.drizzle.com>


JB wrote:
> Hi All,
>
> I'd like to know how I can retrieve the current (or last run) SQL
> statement into a string variable.
> I'm trying to get this so in case of an error I can log the SQL
> statement that caused the error.
> Is there some sort of system variable that would contains it like
> SQLERRM contains the last Error?
>
> Thanks
> JB
>
> Simplified Code sample
>
> BEGIN
> INSERT INTO T1 (ID, NAME)
> VALUES ( 1, 'TEST');
>
> EXCEPTION
> WHEN OTHERS THEN
> sError := SQLERRM;
>
> -- How do I get the SQL statement that cause the error into a String
> variable?
> sSqlStatement := ?????
> END;
If the intention is to slow the system to a glacial crawl then hit GV_$SQLTEXT_WITH_NEWLINES.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Fri Apr 06 2007 - 10:57:41 CDT

Original text of this message

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