I write the code below in order to recuperate the error messages in a table(db_errors) I created. But nothing is inserted in the db_errors table even the statements are wrong. Please advice how to use SQLCODE and SQLERRM.
This is executed in SQL*Plus
DECLARE
err_num NUMBER;
err_msg VARCHAR2(100);
BEGIN
INSERT INTO ...
INSERT INTO ...
UPDATE…
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
err_msg := SUBSTR(SQLERRM(SQLCODE), 1, 250);
INSERT INTO db_errors(err_msg) VALUES (err_msg);
END;
/
Thanks in advance
03-22-2001, 03:05 AM
bensr
I'm not able to try it at this moment, but I think it's the sequence of commands:
EXCEPTION
WHEN OTHERS THEN
-- First save the message
err_msg := SUBSTR(SQLERRM, 1, 100); -- << as defined above
ROLLBACK;
INSERT INTO db_errors(err_msg) VALUES (err_msg);
commit;
END;
03-22-2001, 09:43 AM
Hakimca
Hi,
Thanks ben for your reply,
I changed the sequence but no way.