更新表中的记录 - 嵌套查询

时间:2018-06-06 10:15:29

标签: oracle-sqldeveloper

我在更新此表时遇到问题。这是我的代码:

    UPDATE B594_MAIN b SET CONTATO = TOTAL_PHONE where b.ACCT IN                 
    (SELECT distinct a.CUST_ACCT_EXT_KEY, a.TOTAL_PHONE FROM (
                select d_acct.CUST_ACCT_EXT_KEY, 

                        case
                        WHEN addr.WORK_PH_NUM IS NOT NULL THEN SUBSTR(addr.WORK_PH_NUM,-9,9)
                        when addr.CONTACT_PHONE_NUM_2 is not null then SUBSTR(addr.CONTACT_PHONE_NUM_2,-9,9)
                        WHEN addr.CONTACT_PHONE_NUM IS NOT NULL THEN SUBSTR(addr.CONTACT_PHONE_NUM,-9,9)
                        ELSE 'NO_PHONE'
                        end AS TOTAL_PHONE

                from CDM.DMKV_D_CUSTOMER_ACCOUNT d_acct,
                        CDM.DMKV_D_ADDRESS addr,
                        CDM.DMKV_TRANSP_VAR_RESULT_01 transp_acct

                where d_acct.DW_ADDR_ID = addr.DW_ADDR_ID AND d_acct.CUST_ACCT_EXT_KEY LIKE '3%' AND
                        transp_acct.DW_KEY_ID = d_acct.DW_CUST_ACCT_ID AND transp_acct.CUST_ACCT_ST_DESC = 'Active'

            ) a
        WHERE TOTAL_PHONE LIKE '9%' AND TOTAL_PHONE <> 'NO_PHONE'
    )

当且仅当TOTAL_PHONECONTATO列的B594_MAIN b匹配时,我想将a.CUST_ACCT_EXT_KEY的列中的所有记录更新为ACCT表的B594_MAIN b #ifndef CONTROLLER_THREAD #define CONTROLLER_THREAD #include <QThread> class Worker : public QObject { Q_OBJECT public: Worker(); ~Worker(); private slots: void calculateImage(); signals: void imageReady(); }; class Controller: public QObject { public: Worker objWorker; QThread objQThread; Controller(); ~Controller(); public slots: void receiveImage(); }; #endif // CONTROLLER_THREAD

0 个答案:

没有答案