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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed: how to insert tab? Juha Shell Programming and Scripting 2 10-29-2007 04:15 AM
Insert line break in vi's command mode Skogsmulle UNIX for Dummies Questions & Answers 3 07-06-2007 07:47 AM
unix command to insert double quotes berlin_germany Shell Programming and Scripting 2 01-17-2007 10:07 AM
script to run shell command and insert results to existing xml file littlejon Shell Programming and Scripting 5 08-12-2005 01:59 PM
awk command for INSERT statement nattynatty Shell Programming and Scripting 4 05-10-2002 11:11 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-19-2006
Registered User
 

Join Date: Sep 2005
Posts: 27
sql insert command

Hi,

sqlplus -s / <<EOF > /dev/null
insert into table1 (a1, a2, a3) values ('a',1,'b');
commit;
EOF

in the above code can i pass the values to the insert command from shell script like this:

insert into table1 (a1, a2, a3) values ('$a',$b,'$c');

If yes, how is it passed??

Any help greatly appreciated. (I found some similar threads but culdn't find any particular soln to this)

thanks,

abey
Reply With Quote
Forum Sponsor
  #2  
Old 05-19-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
The problem is that you require ' characters to delimit strings. Here is a workaround not using a here doc:
Code:
userid=me
pswd=mypassword
 command=$(
 echo "$userid/$pswd"
 printf "insert into table1 (a1, a2, a3) values ('%s','%s','%s');\n" $a $b $c
 echo "commit;"
 echo "exit")
 echo "$command" | sqlplus -s
Reply With Quote
  #3  
Old 05-19-2006
Registered User
 

Join Date: Jan 2005
Posts: 682
Code:
a='abc'
b='def'
sqlplus -s / <<EOF
    select '${a}', '${b}' from dual;
EOF

Last edited by tmarikle; 05-19-2006 at 09:07 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0