dbms\u输出:可能缺少一些额外的“enable”

9gm1akwq  于 2021-08-09  发布在  Java
关注(0)|答案(1)|浏览(260)

抱歉这个愚蠢的问题。我被dbms\U输出困住了:
首先,我在batch/sqlplus调用中尝试了它。但是spool文件将只包含消息“pl/sql successfully executed”(见第一部分代码)
我正在oracle database 12c enterprise edition release 12.1.0.2.0上运行代码

Spool D:\log\spool.txt 
Declare
    Some_Num Number := 5;
Begin
    Dbms_Output.Enable(1000000);
    Dbms_Output.Put_Line('Id, Timestamp');
    For Rec In 
    (
        Select 1 As Id, Sysdate As Timestamp From Dual
        Union
        Select 2 As Id, Sysdate As Timestamp From Dual
        Union
        Select 3 As Id, Sysdate As Timestamp From Dual
        Union
        Select 4 As Id, Sysdate As Timestamp From Dual
    )
    Loop
        Dbms_Output.Put_Line( Rec.Id || ', ' ||  Rec.Timestamp );
        -- some code here was actually executed;
    End Loop;
    --Dbms_Output.Disable;
Exception
When Others Then
    Null;
    Dbms_Output.Put_Line('Error');
    --Dbms_Output.Disable;
End;
/
Spool Off
exit;
gcmastyq

gcmastyq1#

我自己找到的。我需要补充一下

SET SERVEROUTPUT ON SIZE 1000000

在剧本的开头。

相关问题