如何在sqlplus中调试Oracle动态sql?
我有一个 PL/SQL 语句,它使用 EXECUTE IMMEDIATE
来执行查询。但是,我很难弄清楚如何获取正在执行的查询的文本。我无法使用 dbms_output
,因为查询超过 255 个字符。有没有办法让 sqlplus 回显传递给 EXECUTE IMMEDIATE
的字符串?
I have a PL/SQL statement that uses EXECUTE IMMEDIATE
to execute a query. However, I'm having difficulty figuring out how to even get the text of the query that's being executed. I can't use dbms_output
as the query is greater than 255 characters. Is there any way to make sqlplus echo the string that's passed in to EXECUTE IMMEDIATE
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您使用什么版本的 Oracle? 255 是
DBMS_OUTPUT.PUT_LINE() 的默认行长度。
在 10g 之前,我们可以在一次调用中显示 1048 个字符。从那时起它是32K。或者,您应该考虑使用支持 DBMS_DEBUG 的 IDE。例如,SQL Developer 就是这样做的,并且它不受 Oracle 的影响。 了解更多信息。
What version of Oracle are you using? 255 is the default line length for
DBMS_OUTPUT.PUT_LINE().
Before 10g we could display 1048 characters in a single call. Since then it is 32K.Alternatively you should consider using an IDE which supports DBMS_DEBUG. For instance, SQL Developer does so, and it is free from Oracle. Find out more.
您可以尝试将探查器附加到数据库(老实说,我只为 SqlServer 这样做过)并运行该过程,因为探查器将显示对数据库进行的任何查询,您将能够在那里拾取它并进行必要的调试。
希望有帮助..
You can try to attach a profiler to the database (honestly I have only done that for SqlServer) and run the procedure since the profiler will show any query made to the DB you will be able to pick it up there and do the necessary debugging.
Hope it helps..
如何一次打印 N 个字符的大字符串。
修改以满足您的需要。
How to print large strings N characters at a time.
Modify to suit your needs.
您可以将字符串插入到日志记录/临时表中并检查它。
You could insert the string into a logging/temporary table and examine it.