I have found multiple examples and have coded my own shell script which will open a single SQL Plus connection and execute a single SQL script
e.g. sqlplus user/pwd @mysqlscript
Is there a way to open a SQL Plus connection in a shell script, keep it open, and pass multiple scripts to this connection before closing it?
e.g.
sqlplus user/pwd
cat script_list.txt | while read scriptname
do
echo executing $scriptname
@$scriptname
done
(yes, I know, but this illustrates idea of what I'm attempting to do)
The reason for this requirement is we will have multiple scripts to execute, but if one fails, then we need to rollback. If I open a new SQL Plus connection for every script (in a loop), when the SQL Plus connection exits, it does its wonderful 'commit on exit' and deprives us of a rollback. Plus, opening/closing SQL Plus can't be great overhead to have.
Are we going to have to construct one big SQL file from the individual scripts, create a save point at the beginning of the script, then execute and exit/rollback on error?
Any help/ideas are greatly appreciated.