How to create error log for stored procedure in oracle 10g?

I need an example of creating an error log file for a stored procedure in oracle. give me an example of creating a table and creating stored procedures and creating an error log.

Thanks in advance

EDIT (relevant information from another question)

Suppose there is a stored procedure. When I execute this stored procedure, some expected error / exception may occur, so I need to create an error log table in which all errors will be automatically saved whenever I execute the stored procedure.

For example, if there is some column that does not allow null values, but the user enters null values, then this error should be generated and should be stored in the error log table.

+3
source share
2 answers

You have not described your requirements in great detail. Here is a simple error log table and error reporting procedure:

CREATE TABLE error_log (ts TIMESTAMP NOT NULL, msg VARCHAR2(4000));

CREATE PROCEDURE log_error (msg IN VARCHAR2) IS
BEGIN
  INSERT INTO error_log (ts, msg)
  VALUES (SYSTIMESTAMP, SUBSTR(insert_log.msg, 1, 4000));
END log_error;

You might need an offline transaction. This will depend on whether you want the log to record errors from procedures that cancel their changes.

As a rule, this will be implemented in a more general logging system, which will record not only errors, but also warnings and debugging information.

, DML (insert/update/delete) ( , ), LOG ERRORS, , , , //, . . , vettipayyan.

, , WHEN OTHERS:

BEGIN
  -- your code here
EXCEPTION
  WHEN OTHERS THEN
    log_error(DBMS_UTILITY.format_error_stack);
    log_error(DBMS_UTILITY.format_error_backtrace);
    RAISE;
END;
+5
+2

Source: https://habr.com/ru/post/1774666/


All Articles