Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sqlplus and spool exception handling in unix script

692864Apr 5 2010 — edited Apr 5 2010
hi i am writing the simple unix shell script as follows. What sort of error handling should i handle and how do i fail the script in case of error? Is there any thing such as EXCEPTION when others that i can use here to log the exception and fail the script?

I see that script can fail for two reasons...1) couldnt connect to db 2) spool error
#!/bin/sh

sqlplus -s scott/tiget@ORCL<<EOF 


set head on
set feedback off
SET NEWPAGE 0
SET SPACE 0
SET ECHO OFF
SET FEEDBACK OFF
SET TERMOUT OFF
SET PAGESIZE 0
SET LINESIZE 500
SET TRIMS ON
set verify off
set colsep ','


spool /usr/path2/cust.csv



select 'usr_id' ||','||'customer_id'  from dual
union all
select usr_id||','||customer_id  from vw_usr_cust


/

exit


EOF 
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2010
Added on Apr 5 2010
1 comment
1,807 views