相关疑难解决方法(0)

dbms_output.put()的缓冲是否与dbms_output.put_line()不同?

我使用Aqua Data Studio通过散布输出结果来调试存储过程.

我在包中有一个违反完整性约束的delete语句:

DELETE FROM x WHERE x.ID = an_x_with_children;
Run Code Online (Sandbox Code Playgroud)

正如预期的那样,我的proc在这一行上失败了ORA-02292.我想看看an_x_with_children变量的值.所以我用这样的输出包装行:

dbms_output.put('Attempting to delete x: ' || an_x_with_children);
DELETE FROM x WHERE x.ID = an_x_with_children;
dbms_output.put(' Success');
Run Code Online (Sandbox Code Playgroud)

并且期望在完整性约束违反错误消息之前将消息视为消息控制台中的最后一件事. 但它不打印!

现在,如果我更改输出以使用如下put_line()过程:

dbms_output.put_line('Attempting to delete x: ' || an_x_with_children);
DELETE FROM x WHERE x.ID = an_x_with_children;
dbms_output.put_line(' Success');
Run Code Online (Sandbox Code Playgroud)

在proc错误出现之前,我立即看到"试图删除x:123"的消息.

文档dbms_output包不提putput_line程序行为有什么不同在这方面.例如,它说

使用PUT或PUT_LINE创建的输出被缓冲.

因此,当proc错误时,我会期望两者都显示或不显示输出.

有人可以向我解释这种行为发生了什么吗?

oracle plsql oracle10g dbms-output

4
推荐指数
1
解决办法
7991
查看次数

标签 统计

dbms-output ×1

oracle ×1

oracle10g ×1

plsql ×1