Win a copy of Mastering Non-Functional Requirements this week in the Design forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to run multiple Updates at once in db2  RSS feed

 
Nag Venkat
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
i ahve a table named collateral.in that table i have a field named URL.
those url values will be like this :ShippingPolicy?storeId=20051&langId=-1&catalogId=10051@productId=675675&categoryId=86789

now i need to replace catalogId,productId etc with neew values instead of existing values.

for that i need to run following queries:
update collateral set url = replace(url, '10379', '32121')
update collateral set url = replace(url, '10512', '33058')
update collateral set url = replace(url, '12001', '32243')
update collateral set url = replace(url, '12002', '32262')
update collateral set url = replace(url, '10307', '32056')
update collateral set url = replace(url, '13501', '32265')
update collateral set url = replace(url, '17002', '32257')
update collateral set url = replace(url, '11003', '32274')
update collateral set url = replace(url, '16501', '32274')

above update statements will work fine.But when we try to run them at once.it will throw error as database won't suppot..
So,is there any option for this,or do we need to run one by one.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36818
481
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to run them one by one. Take a look at the "Performing Parameterized Batch Update" section of this tutorial.

In addition to adding batching, it makes the code a little easier to maintain because you don't have to repeat the same SQL code over and over.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!