How To/sql-db/

Mass update in DB2 database

Yes, it is possible.

Mass update in DB2 database with single query

products - table in database containing information about products
products.item_id - product id
products.itemprice - column with item price

WITH tempprices (iditem, price) AS ( VALUES
 
-- HERE IS DATA PRIVIDED BY USER --
(12, 19.90),
(15, 10.45),
(16, 11.20),
(17, 12.45)
-- END OF DATA PRIVIDED BY USER --
 
)  SELECT COUNT(*) FROM OLD TABLE (
      UPDATE products
      SET products.itemprice = (
         SELECT tempprices.price FROM tempprices WHERE products.item_id = tempprices.iditem
      )
      WHERE
      EXISTS (
         SELECT tempprices.price FROM tempprices WHERE products.item_id = tempprices.iditem
      )
   );