我花了一天中最好的時間試圖確定爲什麼merge語句不起作用,我開始認爲這個問題一定是有點異國情調。這爲什麼不合並聲明工作?
我的數據庫有幾十個使用合併語句的PL/SQL過程,但是我絕對不能讓它工作。雖然它比示例顯示的要大得多,但我已經將其剝離,以便它只更新幾列,但仍然不會編譯。
錯誤是'ORA-00904'別名「。」列名「無效標識符」。這通常意味着列名錯誤輸入,或者在合併的情況下,您試圖更新聯接中使用的字段。這肯定不是這種情況。我已經四重檢查,列名是正確的,它們都存在,並且該語句的格式與我在其他許多地方使用的格式完全相同。
/**
Result: ORA-00904 "P"."SFDC_CUST_CONTACT_PK": invalid identifier
I'm certain that the table and column names are all correct.
If I join on any of the dozen or so other columns instead, I
get the exact same error.
Note: I'm NOT attempting to update the column that I join
against.
**/
merge into customer_contact c
using (select p.fax_number,
p.email
from sfdc_cust_contact_temp p
) p
on (p.sfdc_cust_contact_pk = c.sfdc_cust_contact_pk)
when matched then
update set
c.fax_number = p.fax_number,
c.email = p.email;
/***
This works fine on the same machine
**/
merge into customer_contact_legacy c
using (select ct.contact_legacy_pk,
ct.fax_number,
ct.email
from customer_contact_temp ct
) ct
on (upper(trim(ct.contact_legacy_pk)) = upper(trim(c.contact_legacy_pk)))
when matched then
update set
c.fax_number = ct.fax_number,
c.email = ct.email;
任何想法還有什麼可能是錯誤的嗎?桌子上會不會有一些類型的腐敗?
版本爲10g。
時,在登錄的用戶運行此之下,您問題 'SELECT * FROM ALL_TAB_COLUMNS其中列名=' 會發生什麼? –
Karl
2011-06-03 18:54:48