我使用 Aqua Data Studio 通过分散输出语句来调试存储过程。
我在包中有一条违反完整性约束的删除语句:
DELETE FROM x WHERE x.ID = an_x_with_children;
正如预期的那样,我的过程在该行失败并出现 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');
并期望在完整性约束违反错误消息之前看到消息控制台中的最后一件事。但不打印!
现在,如果我更改输出以使用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');
我在过程出错之前立即看到消息“尝试删除 x: 123”。
The docs为了dbms_output
包中没有提到put
and put_line
程序在这方面表现有任何不同。例如,它说
使用 PUT 或 PUT_LINE 创建的输出会被缓冲。
因此,当过程出错时,我希望两者都不会显示输出,或者都不显示输出。
有人可以向我解释这种行为是怎么回事吗?