Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Capturing ORA errors and inserting into a table.

RE: Capturing ORA errors and inserting into a table.

From: Mandar Shete <mandar.shete_at_tatainfotech.com>
Date: Wed, 08 May 2002 03:48:25 -0800
Message-ID: <F001.0045B380.20020508034825@fatcity.com>


Hi Eva,

That should be simple enough....just capture the SQLCODE and SQLERRM values and insert them in you error table.

DECLARE
    somevars VARCHAR2(10);

    vn_sqlcode	NUMBER(5);
    vc_sqlerrm	VARCHAR2(255);

BEGIN

      SELECT stuff
	INTO somevars
      FROM testtbl;

     BEGIN
         INSERT INTO anothertbl
          (col1)
         VALUES(somevars);
     EXCEPTION
       WHEN OTHERS THEN

		vn_sqlcode := sqlcode;
		vc_sqlerrm := sqlerrm;

		INSERT INTO <error_table> (<col1>, <col2>)
            VALUES (vn_sqlcode, vc_sqlerrm);

     END;

END; Hope that's what you're looking for.

HTH,
Mandar.

-----Original Message-----
Sent: Wednesday, May 08, 2002 4:03 PM
To: Multiple recipients of list ORACLE-L

Hello List

Hope someone can help.
Trying to write a procedure where an event, such as a insert or update is done.
However I would like to capture any oracle error (ORA-......) that is generated, into a table for instance..
i.e.

DECLARE
    somevars VARCHAR2(10);
BEGIN

      SELECT stuff
	INTO somevars
      FROM testtbl;

     BEGIN
         INSERT INTO anothertbl
          (col1)
         VALUES(somevars);
     EXCEPTION
       WHEN OTHERS
	*take oracle ORA error and do something*
	*like insert it into a error table. Not just Output to screen.*
     END;

END; Many Thanks
Denham Eva
Oracle DBA
In UNIX Land
On a quiet Night, you can hear the Windows machines reboot.
############################################################################
#########
This e-mail message has been scanned for Viruses and Content and cleared by MailMarshal
For more information please visit www.marshalsoftware.com
############################################################################
#########
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Denham Eva
  INET: EvaD_at_TFMC.co.za

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mandar Shete INET: mandar.shete_at_tatainfotech.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Wed May 08 2002 - 06:48:25 CDT

Original text of this message

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