我在包中有一个违反完整性约束的delete语句:
DELETE FROM x WHERE x.ID = an_x_with_children;
正如预期的那样,我的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');
并且期望在完整性约束违反错误消息之前将消息视为消息控制台中的最后一件事.但它不打印!
现在,如果我更改输出以使用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');
在proc错误出现之前,我立即看到“试图删除x:123”的消息.
dbms_output包的docs没有提到put和put_line过程在这方面表现不同.例如,它说
Output that you create using PUT or PUT_liNE is buffered.
因此,当proc错误时,我会期望两者都显示或不显示输出.
有人可以向我解释这种行为发生了什么吗?
解决方法 这是一个显示您所看到的行为的示例:sql> exec dbms_output.put_line('hello')helloPL/sql procedure successfully completed.sql> exec dbms_output.put('hello again')PL/sql procedure successfully completed.sql> exec dbms_output.put(' and again')PL/sql procedure successfully completed.sql> exec dbms_output.new_linehello again and againPL/sql procedure successfully completed.
documentation说“sql * Plus在发出SQL语句或匿名PL / sql调用后调用GET_lines”.
并且过程GET_lines说“此过程从缓冲区中检索一行数组.”
有了PUT,你还没有完成你的生产线.所以它不打印.
NEW_liNE过程也提到了这一点:“此过程放置行结束标记.GET_liNE过程和GET_lines过程返回”行“由”换行符“分隔.每次调用PUT_liNE过程或NEW_liNE过程都会生成一行这是由GET_liNE(S)返回的.“
问候,抢.
总结以上是内存溢出为你收集整理的oracle – dbms_output.put()的缓冲是否与dbms_output.put_line()不同?全部内容,希望文章能够帮你解决oracle – dbms_output.put()的缓冲是否与dbms_output.put_line()不同?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)