PL/SQL - Debug.f for debugging application

> Procedural Languages > PL/SQL - (Procedure Language|PL) SQL

1 - About

It's a package designed to allow you to add logging or trace statements to a PL/SQL application.

2 - Example

CREATE PROCEDURE p ( p_owner IN VARCHAR2, p_object_name IN VARCHAR2)
AS
    l_status NUMBER := 0 ;
BEGIN
    Debug.f ('Entering procedure', inputs "%s", "%s" )
    --.... some code ....
    Debug.f ('Normal exit, status = %d', l_status );
END;

If the debug package where told to generate a trace file via a call to debug.init, you will have this :

12062002 213953(P.PROCEDURE  5) Enter procedure inputs "A", "B"
12062002 213955(P.PROCEDURE 56) Normal exit, status = 0

Where :

  • 12062002 is the date MMDDYYYY format
  • 213953 is the time HH24MISS format
Advertising

3 - How to install it

      CREATE USER utility identified BY utility;
      grant CREATE session, CREATE PROCEDURE, CREATE TABLE, CREATE TRIGGER TO utility;
      ALTER USER utility DEFAULT tablespace users quota unlimited ON users;
  • run install_debug in that schema
  • create a public synonym for debug

4 - Reference

lang/plsql/debugf.txt · Last modified: 2017/09/06 22:26 by 108.162.245.86