简体   繁体   English

使用bash脚本在文件中打印DBMS_OUTPUT.PUT_LINE

[英]Print DBMS_OUTPUT.PUT_LINE in a file with a bash script

I have a pl/SQL query that has a variable . 我有一个带有变量的pl / SQL查询。 I want DBMS_OUTPUT.PUT_LINE to a file used on the machine (linux) Does someone know how to do this? 我想DBMS_OUTPUT.PUT_LINE到机器上使用的文件(linux)有人知道怎么做吗?

You need to put some pieces together. 你需要把一些东西放在一起。 Here is my inspiration: DBMS_OUTPUT.PUT_LINE not printing 这是我的灵感: DBMS_OUTPUT.PUT_LINE不打印

a) put your plsql in an sql script, eg d.sql - the key here is set serveroutput : a)将你的plsql放在一个sql脚本中,例如d.sql - 这里的关键是set serveroutput

set serveroutput on size 30000;
begin
   DBMS_OUTPUT.PUT_LINE('my line');
end;
/
exit

b) Then write another script - ksh this time - containing: b)然后写另一个脚本 - 这次是ksh - 包含:

sqlplus /  @d.sql > output.txt

If you want to restrain what displays from , then read appropriate documentation about set statement 如果要限制显示的内容,请阅读有关set语句的相应文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM