[20171211]dbms_output無serveroutput on

lfree發表於2017-12-12

[20171211]如何實現dbms_output輸出沒有開啟serveroutput on.txt

--//作者給出一個簡單的方法:

1.環境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

2.測試:
SCOTT@book> show serverout
serveroutput OFF

SCOTT@book> exec dbms_output.enable(1e6);
PL/SQL procedure successfully completed.

SCOTT@book> exec dbms_output.put_line('aaaa');
PL/SQL procedure successfully completed.

--//沒有輸出.
--//建立指令碼output_print.sql:
var out_c refcursor;

declare
   vt dbmsoutput_linesarray;
   cnt integer;
begin
   dbms_output.get_lines(vt,cnt);
   open :out_c for select COLUMN_VALUE as output from table(vt);
end;
/
col output for a200;
print out_c;
undef out_c
col output clear;

SCOTT@book> @ output_print.sql
PL/SQL procedure successfully completed.
OUTPUT
-----------
aaaa

SCOTT@book> show serverout
serveroutput OFF

3.你僅僅需要在glogin.sql檔案中加入如下就ok了.
set termout off
exec dbms_output.enable(1e6);
set termout on

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2148591/,如需轉載,請註明出處,否則將追究法律責任。

相關文章