2011年3月16日星期三

PL/SQL logging

Once I was in the EBS financial team, created several PL/SQL packages. At that time, we use the FND_LOG.STRING() and FND_FILE.PUT_LINE() functions to logging the temporary results of the procedure/function to debug programs. At that time, I thought those two procedures are Oracle DB's facilities, but it turns out only EBS financial database has such procedures.

In common PL/SQL programs, we have to use the DBMS_OUTPUT.PUT_LINE() function to record the parameters and temporary results of the program.

Further details will be explored in the future.

When logging, you would like to record the procedure/function's name and the line of the source in the message. Two predefined variables are very useful.

$$plsql_line and $$plsql_unit

For $$plsql_line, it's easy. it just show the source code's line.

If your logic is in a simple function/procedure, then $$plsql_unit will display the name of the procedure/function. But when you package your function/procedure in a package, the $$plsql_unit will display the name of the package. So it's not as useful as expected.
Sometimes,  I have to use a variable in the function to store the function's name.