Okay, so I have a script that I'm trying to run that creates a file with an update statement and pipes that to sqlplus to execute. I know that the update statement is valid and it creates the file to send to sqlplus is correct because I have ran just that code in SQL Plus. It just doesn't work when I execute the script. My team and I have looked at this and have tried multiple things, but just can't figure out why it doesn't seem to be executing. Any help would be great. Thanks!
# Update Cycle DUE_DATE_TIME field to target run date
UPDATE_SQL="UPDATE CYCLE SET DUE_DATE_TIME = to_date('${TARGET_RUN_DATE}', 'YYYYMMDD') - 1"
echo $UPDATE_SQL >> ${WORK_AREA}/update_cycle_table_${PROCESS_ID}.sql
echo "${USER_NAME}@${DATABASE}
set line 200
start ${WORK_AREA}/update_cycle_table_${PROCESS_ID}.sql
commit
exit"|sqlplus -s > /dev/null
if [[ $? -eq 0 ]]
then
print "Updated Cycle successfully\n\n"
fi
Okay, so I resolved the issue by making it a bit simpler and instead of just writing it to a file and running that in SQLPlus, I just did the update within the pipe to SQLPlus. I tried to do that before and it wasn't working, but I guess whatever I did this time worked. Thanks everyone for your input!
> /dev/nullso you can see if there are any error messages. Also does$?get set to0? Good luck.echo "$UPDATE_SQL" >> ${WORK_AREA}/....? Hey, why>>should just need>. Good luck.