Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Error handling for most recent SQL
Within a PL/SQL block, how can you capture the text of a failed SQL
statement?
I have a common event logging routine that writes messages to a table. In addition to the SQLERRM, I'd like to write the text of the failed SQL statement with it. Is there a way to do this with PL/SQL without having to first store the statement in a local variable?
For example, if the delete fails below, does Oracle keep a copy of the failed SQL statement for use within the PL/SQL block? How can I get this?
FUNCTION DELETEROW ( vvcRowPK VARCHAR2) RETURN NUMBER IS
lnRC NUMBER; lvcEvent CONSTANT VARCHAR2 := 'DELETEROW' ;
BEGIN
DELETE FROM table_name WHERE column_name = vvcRowPK ; RETURN 1; EXCEPTION WHEN OTHERS THEN lnRC := APP_UTIL.WRITE(APP_NAME,MODULE,lvcEvent, SQLERRM); RETURN -1;
END DELETEROW ; Thanks,
Tony Received on Wed Jan 16 2002 - 17:43:16 CST