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

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

From: JB <jb.brossard_at_gmail.com>
Date: 6 Apr 2007 08:14:23 -0700
Message-ID: <1175872463.190119.7570@o5g2000hsb.googlegroups.com>


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; Received on Fri Apr 06 2007 - 10:14:23 CDT

Original text of this message

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