This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to run multiple Updates at once in db2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to run multiple Updates at once in db2" Watch "How to run multiple Updates at once in db2" New topic
Author

How to run multiple Updates at once in db2

hitendra sunkara
Ranch Hand

Joined: Jul 25, 2013
Posts: 35
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to run multiple Updates at once in db2