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
!
|
|
|
|
Guarantee your Success!
Oracle is the
world's most complex, robust and flexible database, considered
impossible to master without a mentor.
That's why all BC
Oracle trainers are working professionals, experts in Oracle who
share their tips and secrets. |
|
| |
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
feedback. Just
e-mail:
and include the URL for the page.
Copyright © 1996 - 2012
All rights reserved.
Oracle ©
is the registered trademark of Oracle Corporation.
|
|