DBMS_UTILITY.FORMAT_CALL_STACK is used to display the stack information of a procedure or a function.
PL/SQL offers a powerful and flexible exception architecture. Of course, there is always room for improvement, and in Oracle Database 10g, exception handling takes a big step forward with the introduction of the DBMS_UTILITY.FORMAT_ERROR_BACKTRACE function.
Who Raised That Exception?
When an exception is raised, one of the most important pieces of information a programmer would like to uncover is the line of code that raised the exception. Prior to Oracle Database 10g, one could obtain this information only by allowing the exception to go unhandled.
example :
CREATE OR REPLACE PROCEDURE proc1 IS
BEGIN DBMS_OUTPUT.put_line ('running proc1'); RAISE NO_DATA_FOUND; END; / CREATE OR REPLACE PROCEDURE proc2 IS BEGIN DBMS_OUTPUT.put_line ('calling proc1'); proc1; END; / CREATE OR REPLACE PROCEDURE proc3 IS BEGIN DBMS_OUTPUT.put_line ('calling proc2'); proc2; END; /
CREATE OR REPLACE PROCEDURE proc3 IS BEGIN DBMS_OUTPUT.put_line ('calling proc2'); proc2; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line (DBMS_UTILITY.FORMAT_ERROR_STACK); END; /SQL> SET SERVEROUTPUT ON SQL> exec proc3 calling proc2 calling proc1 running proc1 ORA-01403: no data foundDBMS_OUTPUT.PUT_LINE is used to display the information on the screen. This also we can use it for debugging purpose. Only thing we have to use it in all the places of the procedure or function.
No comments:
Post a Comment