I am having problem with a shell script. I have a couple of csv files. The shell script will do some operation on them, create a sql file which will then be called by sqlplus. The problem is to gracefully exit sqlplus at the end of every operation as I do not want to hang on to the connection. But I am getting an error the way I am doing it (see code). Can someone pl. help?
#!/bin/ksh
if [ -e *.csv ]
then
for csvfile in *.csv
do
echo "set feedback off" > temp.sql
echo "set echo off" >> temp.sql
echo "delete from test_table;" >> temp.sql
awk -F, -f parse.awk $csvfile >> temp.sql
echo "commit;" >> temp.sql
rm -f $csvfile
i think you could append exit at the end of the .sql file
and then just execute the .sql file by using:
sqlplus -S uanme/pwd@mydb @temp.sql > test.log
in your loop, you would probably want to rename your log file by concatenating the csvfile to it, just an idea hop it helps