update hi_psndoc_deptchg a set a.lastflag = 'N' where exists (select 1 from from hi_psndoc_deptchg a left join bd_psndoc b on a.pk_psnbasdoc = b.pk_psnbasdoc and a.enddate is not null and b.psnclscope = '0' )
错了 update hi_psndoc_deptchg a set a.lastflag = 'N' where exists (select 1 from hi_psndoc_deptchg a left join bd_psndoc b on a.pk_psnbasdoc = b.pk_psnbasdoc where a.enddate is not null and b.psnclscope = '0' )
update hi_psndoc_deptchg a set a.lastflag = 'N' where a.enddate is not null and a.pk_psnbasdoc= (select pk_psnbasdoc from bd_psndoc b where b.psnclscope = '0' )
这个思路很好,但是报错了:ORA-01427 单行子查询返回多个行
UPDATE HI_PSNDOC_DEPTCHG A SET A.LASTFLAG = 'n' WHERE EXISTS( SELECT 1 FROM BD_PSNDOC B WHERE A.PK_PSNBASDOC = B.PK_PSNBASDOC AND A.ENDDATE IS NOT NULL AND B.PSNCLSCOPE = '0' ); 试试这个看看.我没有测试!
set a.lastflag = 'N'
where
exists (select 1 from from hi_psndoc_deptchg a
left join bd_psndoc b on a.pk_psnbasdoc = b.pk_psnbasdoc
and a.enddate is not null and b.psnclscope = '0' )
update hi_psndoc_deptchg a
set a.lastflag = 'N'
where
exists (select 1 from hi_psndoc_deptchg a
left join bd_psndoc b on a.pk_psnbasdoc = b.pk_psnbasdoc
where a.enddate is not null and b.psnclscope = '0' )
set a.lastflag = 'N'
where a.enddate is not null and a.pk_psnbasdoc=
(select pk_psnbasdoc from
bd_psndoc b where b.psnclscope = '0' )
SET A.LASTFLAG = 'n'
WHERE
EXISTS(
SELECT 1
FROM BD_PSNDOC B WHERE A.PK_PSNBASDOC = B.PK_PSNBASDOC
AND A.ENDDATE IS NOT NULL AND B.PSNCLSCOPE = '0'
);
试试这个看看.我没有测试!