Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> How to get the current/last run SQL statement into a string variable?
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 := ?????
![]() |
![]() |