sql for循环查询转普通查询
sql for loop query to normal query
我有一个 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 查询。
简单地说,这将起作用:
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
)
我有一个 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 查询。
简单地说,这将起作用:
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
)