I'm using SQLERRM. But there are more procedures running parallel, so sometimes SQLERRM is overwritten by other ones. With running parallel I mean I run procedure a and procedure b in the same time.SQLERRM is a global function and it is my problem. If the exception is thrown in both procedures, it could happen, the procedure a modifies the error message in procedure b and procedure b gets the wrong message. These procedures are using simple construction:
BEGIN
--do something/cutted off
EXCEPTION
WHEN OTHERS THEN
write_log(SYSDATE, 'ERROR_1', SQLERRM);
END;
These procedures calls write_log , declared as
CREATE OR REPLACE PROCEDURE WRITE_LOG
(
TS_START IN DATE DEFAULT SYSDATE,
ERR_CODE IN VARCHAR DEFAULT NULL,
ERR_DESC IN VARCHAR DEFAULT NULL
)
IS
BEGIN
INSERT INTO LOG
( LOG_TS_START, LOG_ERR_CODE, LOG_ERR_DESC)
VALUES
(TS_START, ERR_CODE, ERR_DESC);
COMMIT;
END WRITE_LOG;
How can I avoid overwriting of SQLERRM ? The logs are being written, but the error message is wrong.