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 -> Error handling for most recent SQL

Error handling for most recent SQL

From: Tony Krawczyk <tony_krawczyk_at_dell.com>
Date: 16 Jan 2002 15:43:16 -0800
Message-ID: <f2aa4935.0201161543.69a79d71@posting.google.com>


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

Original text of this message

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