使用内部联接更新查询的问题

时间:2017-02-18 07:18:41

标签: oracle

任何人都可以协助让这一个查询工作。我正在尝试更新已加入其他表的表中列的状态

这是查询

update
(select I.account_id, I.sts, I.name_id, CI.CRM_TYPE, I.comments 
  from PPInters I
       inner join DW.CUST CT
       on I.account_id = CT.account_id
        where 
             I.sts is null 
             AND I.comments IS NOT NULL
             AND CT.CUSTTYPe = 'INTNL') T

SET T.STS = 'D'

WHERE T.account_id IN (2000208927,380166014,190180447,166078041,105029075   )

我收到“ORA-01779:无法修改映射到非密钥保留表的列”错误

我在这里要做的是 设置I.STS ='D' 为使用此查询提取的约700条记录

 select I.account_id, I.sts, I.name_id, CI.CRM_TYPE, I.comments 
          from PPInters I
               inner join DW.CUST CT
               on I.account_id = CT.account_id
                where 
                     I.sts is null 
                     AND I.comments IS NOT NULL
                     AND CT.CUSTTYPe = 'INTNL'

我很感激

1 个答案:

答案 0 :(得分:1)

假设account_id是表PPInters中的主要关键词,

UPDATE PPInters
SET STS = 'D'
WHERE account_id IN (

          select I.account_id 
                 /*, I.sts, I.name_id, CI.CRM_TYPE, I.comments */ 
          from PPInters I
               inner join DW.CUST CT
               on I.account_id = CT.account_id
                where 
                     I.sts is null 
                     AND I.comments IS NOT NULL
                     AND CT.CUSTTYPe = 'INTNL'

)
AND account_id IN (2000208927,380166014,190180447,166078041,105029075   )