Oracle PL / SQL - 立即输出/控制台打印的提示 [英] Oracle PL/SQL - tips for immediate output / console printing

查看:328
本文介绍了Oracle PL / SQL - 立即输出/控制台打印的提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些pl / sql程序可能需要几分钟的时间才能运行。在开发过程中,我添加了一些打印语句来帮助调试,并提供一些反馈和进度指标。最初我运行这些小测试集,输出几乎是即时的。现在我正在测试需要几分钟的较大的测试集来运行,我发现打印到控制台已不再适用,因为在程序结束之前没有打印任何内容。我已经习惯了在没有缓冲的输出,并立即加入简单的print语句简单的调试打印和诊断是常见的环境中工作。



是否有可能在pl / sql中打印输出立即(不缓冲)?如果没有,请人推荐什么替代得到同样的结果?


解决方案

您可以有一个表写消息的过程使用自治事务是这样的:

 程序日志(p_message)

编译AUTONOMOUS_TRANSACTION;
begin
insert into message_log(user,datetime,message)
values(user,sysdate,p_message);
提交;
结束



然后监视来自另一个Oracle会话表。


I have a number of pl/sql procedures that can take several minutes to run. While developing them, I've added a few print statements to help debug and also provide some feedback and progress indicators. Initially, I ran these on small test sets and output was almost instantaneous. Now that I'm testing with larger test sets that take several minutes to run, I find that printing to the console is no longer suitable, because nothing gets printed until the procedure ends. I'm used to working in environments that do not buffer their output and print it immediately and adding simple print-statements for simple debugging and diagnostic is common.

Is it possible in pl/sql to print output immediately (not buffered)? If not, what alternatives do people recommend to get a similar result?

解决方案

You can have a procedure that writes messages to a table using an autonomous transaction something like:

procedure log (p_message)
is
    pragma autonomous_transaction;
begin
    insert into message_log (user, datetime, message)
    values (user, sysdate, p_message);
    commit;
end;

Then monitor the table from another Oracle session.

这篇关于Oracle PL / SQL - 立即输出/控制台打印的提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆