我正在嘗試編寫一個簡單的查詢腳本,該腳本可以獲取表中行的cnt數。不過,我面臨的問題是壓制各種oracle消息。所有我感興趣的是輸出:在腳本中運行sql查詢時抑制郵件
這裏是我的腳本:
#!/usr/bin/ksh
sqlplus /nolog <<EOF
connect user/[email protected]
set serveroutput on
set heading off
set feedback off
select count(*) from table;
exit;
EOF
我的輸出是這樣的:
.desktop% sh sql.ksh
SQL*Plus: Release 10.2.0.2.0 - Production on Tue Dec 7 12:00:42 2010
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
SQL> Connected.
SQL> SQL> SQL> SQL>
70
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
我要的是數70沒有任何的消息,讓我可以定期寫入日誌等。我知道我可以解析這個數字,但每當我的查詢或模式發生變化時,我都必須改變它。我不能只是要求mysqlplus壓制所有這些消息嗎?
我同意通過添加-s,即使是我想看到的那些消息也沒有任何消息。問題是如何隱藏所有這些消息,並只顯示我想看到的消息,例如,如果我添加 dbms_output.put_line('Hello Word') 我想只看到Hello Word。我怎樣才能做到這一點??? – vogash 2013-12-25 10:42:22