Hi,
I have the below shell script in which sql file is called which has set of select and insert statements. Right now it's spooling output/error of the sql select /insert commands to the csv file. I want the output and error of the sql commands redirected to the shell script LOGFILE instead of spool file. How can i do it.
LOGPATH=${TEST_LOG}
LOGFILE=${SCRIPTNAME}.$(date '+%Y%m%d_%H%M%S').log
sql_test=${REPORT_HOME}/month_report.sql
exec > ${LOGPATH}/${LOGFILE} 2>&1
main "$@"
exit 0
main()
{
SPOOLTEST="${REPORT}/testreports/report_`date +%Y%m%d_%H%M%S`.csv"
$ORACLE_HOME/bin/sqlplus -s << ENDSQL
${DBLOGIN}@${DBNAME}
WHENEVER SQLERROR EXIT 1 ROLLBACK
WHENEVER OSERROR EXIT 1 ROLLBACK
SPOOL ${SPOOLTEST}
@${sql_test}
SPOOL OFF
ENDSQL
return
}
spool logs after a delay. after shell script logs i am able to find the spool logs. I tried the below one it's not working $ORACLE_HOME/bin/sqlplus -s << ENDSQL >> ${LOGPATH}/${LOGFILE} 2>&1