监控长时间运行的 PL/SQL 块
我有一个相当耗时的 PL/SQL 块,它可以根据分子结构构建指纹。我想将输出打印到 SQL*Plus 控制台,以提供有关已处理的结构数量的反馈。我可以使用 dbms_output.put_line 来完成此操作,
但是每次调用都会写入新行。我想覆盖该行。
例如,目前我有以下内容。
Structure x of y processed
Structure x of y processed
Structure x of y processed
Structure x of y processed
最终,当我处理数千条结构记录时,我填满了缓冲区。
我可以使用一种方法来覆盖最后一个输出行吗?
I have a fairly time intensive PL/SQL block that builds fingerprints from molecular structures. I would like to print output to SQL*Plus console to provide feedback on how many structures have been processed. I can do this with dbms_output.put_line
However everytime that is called a new line is written. I want to overwrite the line.
For example, currently I have the below.
Structure x of y processed
Structure x of y processed
Structure x of y processed
Structure x of y processed
Eventually I fill up the buffer as I'm dealing with thousands of structure records.
Is there a method I can use that will just overwrite the last output line?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 DBMS_OUTPUT 意味着 SQL*Plus 在整个 PL/SQL 块完成之前不会显示任何内容,然后显示缓冲区中当前的所有数据。因此,这不是提供持续状态的适当方式。
另一方面,Oracle 确实提供了一个专门为帮助您而设计的包 DBMS_APPLICATION_INFO监视您正在运行的代码。例如,您可以执行以下操作:
从单独的 SQL*Plus 会话中,您可以通过查询
V$SESSION_LONGOPS
视图来监视进度Using
DBMS_OUTPUT
means that SQL*Plus will display nothing until the entire PL/SQL block is complete and will then display all the data currently in the buffer. It is not, therefore, an appropriate way to provide an ongoing status.On the other hand, Oracle does provide a package DBMS_APPLICATION_INFO that is specifically designed to help you monitor your running code. For example, you could do something like
From a separate SQL*Plus session, you can then monitory progress by querying the
V$SESSION_LONGOPS
view您还可以将消息发送到命名管道,并让另一个进程从管道中读取消息。
You may also send messages to a named pipe and have another process read the message from the pipe.
我认为你不能。据我了解 dbms_output 它只是不能那样工作。
我建议您使用 put 每隔 1000 个左右的条目回显一个点和一个换行符,以查看正在发生的情况,并将当前位置写入表中或对当前位置进行排序,以便您可以查看是否想知道。
I don't think you can. As far as I understood the dbms_output it just doesn't work that way.
I recommend you use put to echo a single dot and a newline every 1000 or so entries to see that something is happening and write into a table or sequence the current position so you can have a look if you want to know.