Multiple UPDATE statements in 1 file. How Do I do it?
Posted in 2001
Topics: General Discussion
I need to make a single file with multiple updates in it. The following update needs to be run a total of 72 times and in each instance the SET AREA and WHERE AREA parameters will be different. UPDATE gc_main SET area[1,2]="W1" WHERE area[3,4]="10" UPDATE gc_main SET area[1,2]="W2" WHERE area[3,4]="23" What is the syntax for running multiple updates? Thanks, John
John wrote in message <3a8083d6.194645047@netnews.voicenet.com>...
>I need to make a single file with multiple updates in it.
>The following update needs to be run a total of 72 times and in each
>instance the SET AREA and WHERE AREA parameters will be different.
>
>UPDATE gc_main
>SET area[1,2]="W1"
>WHERE area[3,4]="10"
>
>UPDATE gc_main
>SET area[1,2]="W2"
>WHERE area[3,4]="23"
>
>What is the syntax for running multiple updates?
Emmm Errr - I think I understand your question.
You want to use an .sql file with dbaccess or isql, correct?
You want to loop over a set of data.
Here's how I would do it using a ksh script instead of an .sql script (which
can't loop):
while read area12 area34; do
echo "update gc_main set area[1,2] = '$area12' where area[3,4] =
'$area34'"
done <<++ | dbaccess mydatabase -
W1 10
W2 23
W3 45
etc etc
++
ksh scripting is very powerful and a whole lot of fun. If it doesn't make
any sense, just use it like a recipe. Have Fun!
Andrew Hamm wrote in message <3a8093db$1@news.iprimus.com.au>... Stop the presses! My echo line needed a semicolon: echo "update gc_main set area[1,2] = '$area12' where area[3,4] = '$area34';" (Thanks Dave)