Question:
I have debugged my PL/SQL with dbms_output.put_line statements and
how that the job is moving into production I need to know where the
output would be written. I know that the put_line
statements are not written anywhere when the PL/SQL is inside a
scheduled job. Does leaving the dbms_output.put_line
statements cause overhead in a production shell script job? Also,
how can I display the output of my dbms_output.put_line
when running the code within a batch job using dbms_scheduler?
Answer: Normally, people
change from dbms_output to utl_file for batch jobs,
but that is not required.
Even if a
dbms_output.put_line writes to /dev/null, the statements
still add overhead . . . .
When I move code into production, I comment out the
dbms_output statements and leave them in the code, in case
I ever need to debug it!
The
put_line works with SQL*Plus when you "set serveroutput
on".
If the job is a UNIX/Linux shell script or a
dbms_scheduler job, you can try using the spool command,
since the PL/SQL is executed via a call to SQL*Plus.
Jon Emmons has lots of working examples in his book "Oracle
Shell Scripting".
Below, we directly spool the output within the PL/SQL, provided that
you invoke the PL/SQL via a call to SQL*Plus:
#!/bin/ksh
# First, we must set the environment . . . .
ORACLE_SID=mon1
export ORACLE_SID
ORACLE_HOME=`cat
/etc/oratab|grep ^$ORACLE_SID:|cut -f2 -d':'`
export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$PATH
export PATH
$ORACLE_HOME/bin/sqlplus system/manager<<!
SET
SERVEROUTPUT ON
SPOOL /tmp/mytrace.txt
BEGIN
. . .
DBMS_OUTPUT.PUT_LINE
END;
/
spool off
!
|
|
Get the Complete
Oracle SQL Tuning Information
The landmark book
"Advanced Oracle
SQL Tuning The Definitive Reference" is
filled with valuable information on Oracle SQL Tuning.
This book includes scripts and tools to hypercharge Oracle 11g
performance and you can
buy it
for 30% off directly from the publisher.
|