2009-10-05 104 views
-1

下面的語句是在存儲過程中 合併成table1的一個甲骨文合併聲明

USING (SELECT a.ROWID row_id, RTRIM(NVL(c.address_line1_text, '')) || ' ' || 
RTRIM(NVL(b.unit_number, '')) address_line1_text, 
RTRIM(c.city_name) city_name, RTRIM(c.state_code) state_code, 
RTRIM(c.basic_zip_code) basic_zip_code, 
NVL(b.unit_number, ' ') unit_number 

FROM table1 a ,table2 b ,table3 c 

WHERE 
    a.program_type_cd = 'P' 

     AND a.development_code = b.development_number 
    ) src 

     ON (a.ROWID = src.row_id) 
     --(ERROR IN LINE BELOW) 
     WHEN MATCHED THEN UPDATE SET street = RTRIM(NVL(src.address_line1_text, '')) 
     || ' ' || RTRIM(NVL(b.unit_number, '')), 

            city = RTRIM(src.city_name), 

            STATE = RTRIM(src.state_code), 

            zip = RTRIM(src.basic_zip_code), 

            unit_number = NVL(src.unit_number, ' '); 

我收到一個錯誤說:

"B"."UNIT_NUMBER": INVALID IDENTIFIER 

回答

0

我想你應該src.unit_number這裏更換b.unit_number

|| ' ' || RTRIM(NVL(src.unit_number, '')), /* <-- */ 

           city = RTRIM(src.city_name), 

           STATE = RTRIM(src.state_code), 

           zip = RTRIM(src.basic_zip_code), 

           unit_number = NVL(src.unit_number, ' '); 
+0

我這樣做後,我發佈了問題,並工作。但是你認爲我在SET語句中做了同樣的事情嗎?例如,如果在SET語句中,我只是說street = src.address_line1_text將不會像street = RTRIM(NVL(src.address_line1_text,'')) || ''|| RTRIM(NVL(b.unit_number,'')) – Drake 2009-10-05 17:58:14

+0

這就是我的想法。謝謝 – Drake 2009-10-05 18:37:07

+0

'street = RTRIM(NVL(src.address_line1_text,''))|| ''|| RTRIM(NVL(b.unit_number,''))'等於(根據表a,b和c):RTRIM(NVL(R.RIMIM(NVL(c.address_line1_text,''))||'' || RTRIM(NVL(b.unit_number,'')),''))|| ''|| RTRIM(NVL(NVL(b.unit_number,''),''))' 我想你只想要'street = src.address_line1_text' – manji 2009-10-05 18:37:32