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
sed: how to insert tab? Juha Shell Programming and Scripting 2 10-29-2007 07:15 AM
Insert line break in vi's command mode Skogsmulle UNIX for Dummies Questions & Answers 3 07-06-2007 11:47 AM
unix command to insert double quotes berlin_germany Shell Programming and Scripting 2 01-17-2007 01:07 PM
script to run shell command and insert results to existing xml file littlejon Shell Programming and Scripting 5 08-12-2005 05:59 PM
awk command for INSERT statement nattynatty Shell Programming and Scripting 4 05-10-2002 03:11 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 05-19-2006
abey abey is offline
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
  #2 (permalink)  
Old 05-19-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,787
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

  #3 (permalink)  
Old 05-19-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683

Code:
a='abc'
b='def'
sqlplus -s / <<EOF
    select '${a}', '${b}' from dual;
EOF


Last edited by tmarikle; 05-19-2006 at 01:07 PM..
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 02:27 PM.


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