Oracle:DBMS_OUTPUT 包有替代品吗?
尤其是没有 256 个最大字符/行的 和 1000000 个最大字符/缓冲区限制。
especially one that doesn't have the 256 max chars/line
and 1000000 max chars/buffer limitation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
也许这些选项之一会满足您的需求(取决于您是在服务器端还是客户端编写内容):
(由 Mark Harrison 更新)我在 AskTom 帖子中使用了 my-dbms-output 包。 一个非常好的功能是您可以通过视图访问结果,这样就可以轻松地在客户端程序中显示输出。 我将其重命名为更短的名称。
Maybe one of these options will suit your needs (depending whether you write something on server side or client side):
(update by Mark Harrison) I went with the my-dbms-output package in the AskTom post. One really nice feature is that you can access the results via a view, so that it's easy to show the output in a client program. I renamed it to a shorter name.
什么版本的Oracle? 这两个限制在最近的版本中都得到了放松。 10.2 支持长度超过 255 个字符的行(新限制为 32k),并消除了最大缓冲区大小限制。 Oracle 9.2 有每行 255 个字符/总大小 1 MB 的限制,但 Oracle 已不再支持该版本。
What version of Oracle? Both of those limitations have been relaxed in recent versions. 10.2 supports lines longer than 255 characters (the new limit is 32k) and eliminates the maximum buffer size limitation. Oracle 9.2 had the 255 characters per line/ 1 MB total limit, but Oracle has desupported that version.
INSERT 是一个绝佳的选择。 您不仅可以从流程中获取信息,还可以保留这些信息以供将来参考或分析。 可以使用称为 SQL 的非常通用的语言来检索、过滤和处理结果。 您可以有一个默认值为 sysdate 的列来检查时间和顺序。 它可以放置在自治事务中,以避免由于回滚而丢失日志记录。
INSERT is a fantastic alternative. Not only do you get the information out of your process, it's persisted for future reference or analysis. And the results can be retrieved and filtered and processed with a very common language called SQL. You could have a column with a default of sysdate to check time and order. It can be placed inside an autonomous transaction to avoid losing the logging due to a rollback.
您可以使用 TCP 包将输出写入终端或远程数据记录器。 非常适合调试在计划任务中运行的包代码。
编辑:这是一个示例过程:
You can use the TCP package to write output to a terminal or to a remote data logger. Quite handing for debugging package code running in scheduled tasks.
Edit: Here is an example procedure:
另一种选择(尽管可能不是一个很好的选择)是写入警报日志。
Another option, although probably not a great one, is to write to the alert log.
dbms_output 的一个限制是输出仅在语句完成后才可用。 为了跟踪长时间运行的进程,我使用 dbms_pipe 发送状态消息。 在管道的另一端,您可以看到该过程的进展情况。
One limitiation of dbms_output is that the output becomes available only after the statement has finished. To keep track of long running processes I use dbms_pipe to sent out status messages. On the other end of the pipe you can then see what the process is up to.