Spool only data - no SQL Commands in the log file

Here is a shell script to run SQL commands and spool only the output (Not the SQL Command or any other lines from your script).

(** The trick is to use "sqlplus -S" option)


$ cat test01.sh

sqlplus -S /nolog << EOF

CONNECT system/xxxxx@mydb

set trim on trims on
set echo off
set feedback off
set define off

spool test01.log


SELECT SUM(PERCENT_SPACE_USED) USED_PERCENT FROM V\$FLASH_RECOVERY_AREA_USAGE HAVING SUM(PERCENT_SPACE_USED) > 10;

spool off

exit;

EOF

$ ./test01.sh

USED_PERCENT
------------
       20.69
$ cat test01.log

USED_PERCENT
------------
       20.69
$

No comments:

Post a Comment

ASM and Database does not auto start in Oracle restart environment (After Server start)

 If you are supporting Any Oracle restart environment and if you notice that your ASM instance and Database instance does not start automati...