私はあなたが以下のようなことを達成しようとしていると思います(テーブルPREDICATE
の列であると考えてTRANSFER
ください)-
MERGE INTO TRANSFER st
using (select CASE
WHEN dv.dom_value = 'ZZZZ' THEN 'SPB'
WHEN dv.dom_value = 'XXXX' THEN 'SPB'
WHEN dv.dom_value = 'YYYY' THEN 'SPB'
ELSE 'DPS'
END as key,
val_id
from DOMAIN_VALUES) dv
on (dv.val_id = st.sr_cashflow_status and st.PROCESS_STATUS is NULL)
WHEN MATCHED THEN
UPDATE SET PROCESS_STATUS = concat(PREDICATE,dv.key);
また
MERGE INTO TRANSFER st
using (select CASE
WHEN dv.dom_value = 'ZZZZ' THEN 'SPB'
WHEN dv.dom_value = 'XXXX' THEN 'SPB'
WHEN dv.dom_value = 'YYYY' THEN 'SPB'
ELSE 'DPS'
END as key,
val_id
from DOMAIN_VALUES) dv
on (dv.val_id = st.sr_cashflow_status and st.PROCESS_STATUS is NULL)
WHEN MATCHED THEN
UPDATE SET PROCESS_STATUS = PREDICATE||dv.key;
CASE
ステートメントの構文に関する簡単なメモ。CASE
this を句で使用しているため、結果を何も比較しないため、構文が正しくないように見えます。また、WHERE
句も欠落していAND
ます。
update TRANSFER set PROCESS_STATUS = concat ( PREDICATE ,
(select dom_value from DOMAIN_VALUES dv where dv.val_id = st.sr_cashflow_status
CASE PREDICATE WHEN dv.dom_value = 'ZZZZ' THEN 'SPB' -- and clause missing
WHEN dv.dom_value = 'XXXX' THEN 'SPB'
WHEN dv.dom_value = 'YYYY' THEN 'SPB'
ELSE 'DPS'
END )) --comparison missing like CASE ... END = 'SPB' since the case is inside WHERE
from TRANSFER st -- you cannot have a FROM clause in UPDATE
where PROCESS_STATUS is null;