Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Using dbms_output.put_line in Scheduled Job Script

Expert Oracle Database Tips by Donald BurlesonFebruary 22, 2015

 

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.

 

 

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.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.


 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster