1

Perhaps a silly question, but say I have a logging procedure like so (greatly simplified for brevity):

 PROCEDURE LOGGER (
    p_TYPEOFLOG             IN  VARCHAR2,
    p_LOGSEVERITY           IN  VARCHAR2,
    p_SESSIONID             IN  VARCHAR2)
 AS
    v_timestamp             DATE := SYSDATE;

 BEGIN

    PRAGMA autonomous_transaction;

    BEGIN
        INSERT INTO Log (
            TypeOfLog, LogSeverity, SessionID, TimeOfAction)
        VALUES (
            p_TYPEOFLOG, p_LOGSEVERITY, p_SESSIONID, v_timestamp);
        COMMIT;
    END;

END LOGGER;

Now, usually I would wrap the begin/end bit up with an exception handler, which would call this logger procedure. But what do I do if I'm already in the Logger? Do I simply do an exception if when others null and skip it? Do I try calling the Logger procedure again? What is standard here?

1
  • If you called the Logger procedure again, and that failed again - if it's a wider problem like running out of space, say - how would you prevent infinite recursion adding to your problems? Oracle might try to kill the recursion, but you'd catch and try to log that too... Commented Nov 6, 2014 at 16:28

1 Answer 1

4

I don't believe that there is such a thing as "standard".

Personally, if my logging code failed, I'd let whatever exception was generated be thrown and propagate up the stack. If you can't write to the Log table, that implies that something terribly unfortunate has happened. I wouldn't want to catch and ignore such an exception. And given no other way to log the error, I'd raise the exception back to the caller and expect the caller to either display the message to a user (i.e. a stack trace in the front end web app) or to log the message to an application server log.

Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.