dbms_output.put()的缓冲与dbms_output.put_line()的缓冲不同吗? [英] Is dbms_output.put() being buffered differently from dbms_output.put_line()?

查看:100
本文介绍了dbms_output.put()的缓冲与dbms_output.put_line()的缓冲不同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Aqua Data Studio通过在各处分散输出语句来调试存储的过程.

Im using Aqua Data Studio to debug a stored proc by scattering output statments throughout.

我的软件包中有一条delete语句,它违反了完整性约束:

I have a delete statement in the package which violate an integrity constraint:

DELETE FROM x WHERE x.ID = an_x_with_children;

我的进程按预期失败,并在此行上显示ORA-02292.我想查看an_x_with_children变量的值.所以我用如下输出将行包装起来:

My proc fails with an ORA-02292 on this line, as expected. I want to see the value of the an_x_with_children variable. So I wrap the line with outputs like so:

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');

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

And expect to see the message as the last thing in the messages console prior to the integrity constraint violated error message. But it doesn't print!

现在,如果我将输出更改为使用像这样的put_line()过程:

Now if I change the output to use the put_line() procedure like this:

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".

I see the message "Attempting to delete x: 123" immediately before the proc errors out.

dbms_output软件包的 docs 不要提及putput_line过程在这方面有任何不同.例如,它说

The docs for the dbms_output package don't mention the put and put_line procedures behaving any differently in this respect. For instance, it says

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

Output that you create using PUT or PUT_LINE is buffered.

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

So I would expect either both or neither to show output when the proc errors.

有人可以向我解释这种行为是怎么回事吗?

Can someone explain what's going on with this behaviour to me?

推荐答案

以下是显示您所看到的行为的示例:

Here is an example that shows the behaviour you're seeing:

SQL> exec dbms_output.put_line('hello')
hello

PL/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_line
hello again and again

PL/SQL procedure successfully completed.

文档说,"SQL * Plus在发布SQL之后调用GET_LINES语句或匿名PL/SQL调用."

The documentation says "SQL*Plus calls GET_LINES after issuing a SQL statement or anonymous PL/SQL calls."

过程GET_LINES说:此过程从缓冲区中检索行的数组."

And procedure GET_LINES says "This procedure retrieves an array of lines from the buffer."

使用PUT,您尚未完成生产线.因此它不会打印.

With PUT you haven't completed your line yet. And so it doesn't print.

NEW_LINE过程也提到了这一点:此过程放置了行尾标记.GET_LINE过程和GET_LINES过程返回由"newlines"分隔的行".每次调用PUT_LINE过程或NEW_LINE过程生成由GET_LINE(S)返回的行."

The NEW_LINE procedure mentions this as well: "This procedure puts an end-of-line marker. The GET_LINE Procedure and the GET_LINES Procedure return "lines" as delimited by "newlines". Every call to the PUT_LINE Procedure or NEW_LINE Procedure generates a line that is returned by GET_LINE(S)."

关于,
罗布.

Regards,
Rob.

这篇关于dbms_output.put()的缓冲与dbms_output.put_line()的缓冲不同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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