If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > How to do an update in Informix DB by using a value from a korn shell

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-10, 04:29
gururaj911 gururaj911 is offline
Registered User
 
Join Date: Nov 2010
Posts: 2
Exclamation How to do an update in Informix DB by using a value from a korn shell

Hi,

i've written korn shell script. But when i try to do an update to Informix db in the same shell script, the value in the shell script is not getting passed onto the update command.Find my script below:

#!/usr/bin/ksh
INFORMIXDIR=xxxxxxx; export INFORMIXDIR
INFORMIXSERVER=xxxxxxx; export INFORMIXSERVER
ONCONFIG=xxxxxxxxxxx; export ONCONFIG
PATH=xxxxxxxxxx; export PATH

while read line
do
field1=`echo $line | cut -d',' -f1`
value=$field1
echo 'update table set typ1="ABC AB A/B" where type2="$value"' | dbaccess dbc

done < "$1"



here i am passing a .csv file as command line argument which contains values like A ABCD ABCD A1,ABC AB A/B
B BCAD BCAD B2,ABC AB A/B


i am cutting the first part of the line using comma(,) as delimiter and saving it in a variable. but when i pass that variable to update command, the table is not getting updated.

Could you please help me solve this.
Reply With Quote
  #2 (permalink)  
Old 11-19-10, 08:08
ibm.ids ibm.ids is offline
Registered User
 
Join Date: Nov 2008
Posts: 64
you shozld write:

echo 'update table set typ1="ABC AB A/B" where type2="'$value'"'

notice single quotes arround $value
Reply With Quote
  #3 (permalink)  
Old 11-20-10, 04:20
gururaj911 gururaj911 is offline
Registered User
 
Join Date: Nov 2010
Posts: 2
How to do an update in Informix DB by using a value from a korn shell

Thanks a lot ibm.ids. that worked
Reply With Quote
Reply

Tags
informix, korn, update

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On