Reputation: 710
I've been looking everywhere, and the posts suggest to pipe the echo exit | sqlplus @script.sql
but my script contains PL/SQL statements, that take input, so as soon as the PROMPT
message is outputted, the exit
kicks in and the script exits.
Here's the linux call
alias sql 'sqlplus -s user/pass'
sql @test.sql
The script executes fine and does the INSERT
in the DB, but then it just waits for me to type the exit once it executes.
Any ideas?
Upvotes: 2
Views: 5371
Reputation: 191285
The obvious thing to do is to modify your script to have exit
at the end. If you can't do that you can create a temporary file that does it, e.g.:
(cat test.sql && echo exit) > /tmp/test_$$.sql
sql @/tmp/test_$$.sql
rm -f /tmp/test_$$.sql
The $$
in the file name is substituted with the current process's ID (PID), so if the script is run twice simultaneously each will get a different file name; and then it's removed at the end. (You can do a protective delete first, or check it doesn't already exist, just in case an earlier removal failed somehow).
Upvotes: 4