分类: DB2/Informix
2011-10-10 16:53:15
需求:
想把键值CONTAINER指定值时改为另外的值然后insert。下面是两种方法:
-- use CASE condition to change field value
INSERT INTO PTRLIB/HAZMAT
select
CASE CONTAINER
WHEN 'CNTR0001' THEN 'AAAA'
WHEN 'CNTR0002' THEN 'BBBB'
END,
QUANTITY
from ptrlib/hazmat;
-- use select constant value to change field value.
INSERT INTO PTRLIB/HAZMAT
select 'aaaa',quantity+1 from ptrlib/hazmat where container='CNTR0001';
----------
over
欢迎讨论。