The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
oracle connection from shell script DILEEP410 Shell Programming and Scripting 4 07-01-2009 03:19 AM
sybase connection through shell-script Amitabh UNIX for Dummies Questions & Answers 9 04-10-2009 11:34 PM
Logging into oracle or SQL from shell script manirsendhil Shell Programming and Scripting 2 04-10-2007 12:46 AM
run shell script from oracle store procedure arnabb4u Shell Programming and Scripting 8 08-16-2006 01:16 PM
Shell script on Oracle hot backup got an error oradbus UNIX for Advanced & Expert Users 1 01-03-2006 12:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-13-2002
nattynatty nattynatty is offline
Registered User
  
 

Join Date: Apr 2002
Posts: 31
Unhappy shell script- oracle connection problem

Hi all,

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

sqlplus -S uanme/pwd@mydb @temp.sql > test.log <<
endsqlplus
done

endsqlplus
exit 0

fi
  #2 (permalink)  
Old 08-13-2002
edog edog is offline
Registered User
  
 

Join Date: Sep 2001
Location: Green Bay, WI
Posts: 66
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



i.e.

#!/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
echo "exit;" >> temp.sql
rm -f $csvfile

sqlplus -S uanme/pwd@mydb @temp.sql > test.$csvfile.log
done

exit 0

fi
  #3 (permalink)  
Old 08-13-2002
peter.herlihy peter.herlihy is offline
Registered User
  
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
That's right...you append it within the sql fiel and you'll be fine. I've used approach this before.
  #4 (permalink)  
Old 08-13-2002
tavaresd tavaresd is offline
Registered User
  
 

Join Date: Jun 2002
Posts: 6
Try this.

#!/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
echo "exit;" >> temp.sql
rm -f $csvfile

sqlplus -S uanme/pwd@mydb <<EOF
@temp.sql
exit 0
EOF
done
fi

Good Luck!
  #5 (permalink)  
Old 08-14-2002
nattynatty nattynatty is offline
Registered User
  
 

Join Date: Apr 2002
Posts: 31
Thanx for all the suggestions. The exit thing works perfectly fine.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:06 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0