暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

How can I get a PL/SQL procedure to output debugging messages ?

2011-01-01
655

The Oracle (tm) Users' Co-Operative FAQ

How can I get a PL/SQL procedure to output debugging messages.


Author's name: Keith Jamieson

Author's Email: keith_jamieson@hotmail.com

Date written: 25th July 2001

Oracle version(s): 7.3.4,8.0.6,8.1.7

When people first start to code and debug Oracle procedures, they start using DBMS_OUTPUT.PUT_LINE, and when they test  the code using SQLPLUS,  their debug messages do not appear.  Sometimes debug messages appear before a procedure call, but not afterwards.


The most important aspect is to tell sqlplus to display output from the server to the screen. This can be done by issuing the following sqlplus command: set serveroutput on.   I have a couple of simple rules which get me around most problems:

I always issue set serveroutput on before running a procedure that I want to debug.

I always issue a  dbms_output.enable statement after a call to a procedure. This is because a dbms_output.disable statement may have been issued by any  procedure which may have been called during the code execution.

In addition, after I have made any appropriate changes, and recompiled the procedure, I again issue set serveroutput on before re-executing the code. 

There is an alternative, to using dbms_output, and that is to create a table especially for debugging purposes, and insert your error messages into this table.  If you want to see these messages in another session, then of course, you will have to have committed your transaction.    

For serious debugging purposes, eg extremely large or complex  programs, or tracing code execution, I strongly advocate the use of a PL/SQL editing/debugging tool. There are a number of such tools on the market, provided by both Oracle(tm) and other vendors.   


Further reading: SQL*PLUS Users Guide and Reference. See also the FAQ item: How can I get a PL/SQL procedure to output high volumes of debugging messages ?



最后修改时间:2020-04-16 15:12:53
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论