如何从通过数据库链接执行的存储过程中进行假脱机?

发布于 2024-12-29 10:15:12 字数 765 浏览 0 评论 0原文

我正在使用 UNIX 脚本来运行 sql 代码,该代码通过数据库链接启动存储过程。我可以成功完成该过程,但是没有任何 DBMS 输出被假脱机到指定的 SPOOL 文件。

UNIX 中的 SQL:

set feedback off;
set linesize 500;
set serveroutput on size 1000000;
set serveroutput on format wrapped;
spool $SQLspool;

whenever oserror exit;
whenever sqlerror exit sql.sqlcode;

DECLARE

retcode integer :=0;

BEGIN

owner.procedure@db;

dbms_output.put_line('');
dbms_output.put_line('return code: ' || retcode);
dbms_output.put_line('');


EXCEPTION
        WHEN OTHERS THEN
        RAISE;  

END;
/
EXIT;

SPOOLFILE 内容:

return code: 0

我在存储过程中列出了一堆 DMBS 输出,但没有任何内容写入假脱机文件。

如何让它输出到假脱机文件?

我尝试使用 IN OUT 变量,但由于该过程包含 COMMIT,因此它会因参数而出错,因为它正在通过 DB Link...

I am using a UNIX script to run sql code that kicks off a stored procedure via database link. I can get the procedure to complete successfully, however none of the DBMS outputs are spooled to the SPOOL file indicated.

SQL within UNIX:

set feedback off;
set linesize 500;
set serveroutput on size 1000000;
set serveroutput on format wrapped;
spool $SQLspool;

whenever oserror exit;
whenever sqlerror exit sql.sqlcode;

DECLARE

retcode integer :=0;

BEGIN

owner.procedure@db;

dbms_output.put_line('');
dbms_output.put_line('return code: ' || retcode);
dbms_output.put_line('');


EXCEPTION
        WHEN OTHERS THEN
        RAISE;  

END;
/
EXIT;

SPOOLFILE CONTENTS:

return code: 0

I list a bunch of DMBS outputs within the stored procedure but nothing is written to the spool file.

How can I get it to output to the spool file?

I tried to have IN OUT variables, but because the procedure contains COMMITs it errors out with the parameters since it is going through the DB Link...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

孤者何惧 2025-01-05 10:15:12

PUT 和 PUT_LINE 的输出被缓冲。来自 Oracle 文档
:

在 PL/SQL 程序完成之前,SQL*Plus 不会显示 DBMS_OUTPUT 消息。 PL/SQL 程序中没有刷新 DBMS_OUTPUT 缓冲区的机制。

因此,如果您希望流式传输响应,您将需要编写一个不缓冲输出的小程序。

The output for PUT and PUT_LINE is buffered. From the Oracle docs
:

SQL*Plus does not display DBMS_OUTPUT messages until the PL/SQL program completes. There is no mechanism for flushing the DBMS_OUTPUT buffers within the PL/SQL program.

So, if you are looking to stream responses you are going to need to write a small program which does not buffer the output.

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