更新:
merge into pj_milestone_batch a
using (select (PLANYEAR || countycompanyorder || inverstbatch) as sortruler,
‘0001’ as sortserial,id
from pj_milestone_batch b
where sortruler is null
and sortserial is null and inverstbatch is not null) c
ON (a.id = c.id)
when matched then
update set a.sortserial = c.sortserial, a.sortruler = c.sortruler
插入:
insert into pj_milestone_batch (sortruler,sortserial) values
–这里查出来你要插入的两条数据
select (year||countycompanyorder||inverstbatch) as sortruler,’0001’ as sortserial
from pj_milestone_batch where sortruler is null and sortserial is null