如何在sqlplus中调试Oracle动态sql?

发布于 2024-08-09 15:39:16 字数 190 浏览 6 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

骄傲 2024-08-16 15:39:16

您使用什么版本的 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.

丑丑阿 2024-08-16 15:39:16

您可以尝试将探查器附加到数据库(老实说,我只为 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..

风情万种。 2024-08-16 15:39:16

如何一次打印 N 个字符的大字符串。
修改以满足您的需要。

FOR i IN 0..10 LOOP
  dbms_output.put_line(substr(my_very_long_string,i*100+1,100));
END LOOP;

How to print large strings N characters at a time.
Modify to suit your needs.

FOR i IN 0..10 LOOP
  dbms_output.put_line(substr(my_very_long_string,i*100+1,100));
END LOOP;
你对谁都笑 2024-08-16 15:39:16

您可以将字符串插入到日志记录/临时表中并检查它。

You could insert the string into a logging/temporary table and examine it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文