Hi,
instread of two updates I would like to write only one update. Is is posible to write update statement using case statement?
Sample:
Code:
Table looks like this:
SELECT * FROM DB2ADMIN.TABLE
A B
-- ---
00 A01
00 A02
Instread of writting two update statements...
Code:
UPDATE DB2ADMIN.TABLE SET A='01' WHERE A = '00' AND B='A01'
UPDATE DB2ADMIN.TABLE SET A='02' WHERE A = '00' AND B='A02'
... I would like to write one statement:
Code:
UPDATE DB2ADMIN.TABLE SET A =
CASE
WHEN A='00' AND B = 'A01' THEN A='01'
WHEN A='00' AND B = 'A02' THEN A='02'
END
I have seen this sample on page
SQL Server update - using CASE Expressions. Is this posible on DB2 database?
My system: DB2 v8.2fp9 on Windows XP SP2