I m trying to update a table using MERGE in DB2 query.
Query looks like as given below:
MERGE INTO AMTTABLE A
USING (SELECT CTRY_CODE,CO_CODE, ITEM_ID, AMT FROM AMTTABLE) B
ON ( B.CTRY_CODE = A.CTRY_CODE
AND B.CO_CODE = A.CO_CODE
AND B.ITEM_ID = A.ITEM_ID )
AND B.AMT <> A.AMT
THEN UPDATE SET A.AMT = B.AMT
WHEN NOT MATCHED THEN
SIGNAL SQLSTATE '70002'
I think that, in your case, you could just use an UPDATE to update the table...
But it seems you want to change all AMT values to one unique value for all rows having same CTRY_CODE, CO_CODE and ITEM_ID.
Is that what you really want to do ?