我有一个for循环查询,我试图在不循环的情况下进行更改,并尝试对一条记录进行外循环验证。
所以,我正在寻找没有循环的普通查询。
<query name="validate2">
<![CDATA[
begin
for rec in (
select staging.profileId as sfId
from staging_pricematch_adj staging
left outer join client cl
on staging.profileId = cl.salesforce_Id
where staging.rejectcode is null
and cl.salesforce_Id is null
) loop
update staging_pricematch_adj
set rejectcode = '002',
rejectReason = 'INVALID_PROFILE_ID'
where profileId = rec.sfId;
end loop;
end;
]]>
</query>
我正在寻找没有循环条件的noraml查询。
答案 0 :(得分:2)
简单地说,这将起作用:
update staging_pricematch_adj
set rejectcode = '002',
rejectReason = 'INVALID_PROFILE_ID'
where profileId IN (
select staging.profileId
from staging_pricematch_adj staging
left outer join client cl
on staging.profileId = cl.salesforce_Id
where staging.rejectcode is null
and cl.salesforce_Id is null
)