如何正确输出PL/SQL [英] How to properly output PL/SQL

查看:103
本文介绍了如何正确输出PL/SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.sql文件中有两个代码块.一个块是一个功能,另一个是一个过程.在第一个块中,我正在运行查询并将其自己的每一行打印到屏幕上(我正在使用DBMS_OUTPUT.PUT_LINE()).然后,该过程还有另一个查询,需要在同一行上打印(我正在使用DBMS_OUTPUT.PUT()).当我将DBMS_OUTPUT.PUT()用于第二个块时,由于某种原因,它会拧紧第一个块,并且第一个块永远不会打印.

I have two blocks of code inside a .sql file. One block is a function and another is a procedure. In the first block, I'm running a query and printing it out to the screen (I'm using DBMS_OUTPUT.PUT_LINE() ) for each row in it's own line. Then the procedure has another query which needs to be printed on the same line (I'm using DBMS_OUTPUT.PUT() ). When I use DBMS_OUTPUT.PUT() for the second block, it screws up the first block for some reason and the first block never prints.

以下是代码的链接: http://pastebin.com/z29emmBJ (代码的相关部分在第97-103行)

Here's a link to the code: http://pastebin.com/z29emmBJ (The relevant part of the code is around lines: 97-103)

当我在过程内部使用DBMS_OUTPUT.PUT_LINE()时,一切都会正确显示,但是当我在过程内部使用DBMS_OUTPUT.PUT()时,似乎该函数从未被调用.

When I have DBMS_OUTPUT.PUT_LINE() being used inside of the procedure, everything displays properly, but when I have DBMS_OUTPUT.PUT() inside of the procedure, it looks like the function never gets called.

这是PUT_LINE()的输出结果: http://i.imgur.com/AnCv9 .png 这就是仅使用PUT()的输出结果: http://i.imgur.com/Jv3SV.png

Here's what the output looks like with PUT_LINE(): http://i.imgur.com/AnCv9.png Here's what the output looks like with just PUT(): http://i.imgur.com/Jv3SV.png

我认为这与缓冲区大小有关,但是我不确定是什么原因.

I think it has something to do with the buffer size, but I'm not exactly sure what/why.

任何帮助将不胜感激!

推荐答案

为什么不根据需要将结果仅附加到VARCHAR2变量中,然后在行完成时将字符串附加到该字符串上?这样,您就可以控制格式.

Why don't you just append the results to a VARCHAR2 variable as needed, then put_line that string when the row is completed? That way you have control over the formatting.

这篇关于如何正确输出PL/SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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