【问题标题】:sql for loop query to normal querysql for 循环查询到普通查询
【发布时间】:2020-10-23 04:31:17
【问题描述】:

我有一个 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>

我正在寻找没有循环条件的普通查询。

【问题讨论】:

    标签: sql database for-loop plsqldeveloper


    【解决方案1】:

    简单地说,这将起作用:

          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
    
          )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多