oracle : 无法更新 ON 子句中引用的列

下面这个句子总是无法执行,提示:无法更新 ON 子句中引用的列: "PT"."GROUP_CODE"

原因:on中 "PT"."GROUP_CODE"已经用作了匹配,无法在update里又做更改,需要去掉匹配才能做update操作。

merge into t_procedure_test pt
using (select ro.route_groupid, ro.group_next group_name,tec.TECHNICSID,tec.TECHNICSNAME
--,tec.MODEL_CODE,tec.ENABLED,tec.MO_NUMBER,tec.ROUTE_CODE, ro.group_code
from t_smo_technics tec ,t_co_route_control ro
where tec.MODEL_CODE='1002000005051' and tec.route_code=ro.route_code and ro.group_next='NBPACK-FINAL-TEST') gro
on (gro.TECHNICSID=pt.TECHNICS_ID and gro.route_groupid=pt.GROUP_CODE)
when matched then
update set pt.GROUP_CODE='Test'
when not matched then
insert (TECHNICS_ID,TECHNICS_NAME,group_name,group_code,test_item_id) values(000,'test','test','000',000);

猜你喜欢

转载自www.cnblogs.com/hanje/p/10614814.html