[20171211][转载]如何实现dbms_output输出没有打开serveroutput on.txt

[20171211]如何实现dbms_output输出没有打开serveroutput on.txt

http://orasql.org/2017/12/10/sqlplus-tips-8-dbms_output-without-serveroutput-on/

--//作者给出一个简单的方法:

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

上一篇:uboot下emmc内容烧写(拷贝)步骤


下一篇:CSS语法与用法小字典