1 日の大半をマージ ステートメントが機能しない理由を特定することに費やしましたが、この問題は少し変わったものに違いないと思い始めています。
私のデータベースには、merge ステートメントを使用する多数の PL/SQL プロシージャがありますが、特定の 1 つを機能させることは絶対にできません。示されている例よりもはるかに大きいですが、いくつかの列を更新するだけでコンパイルできないように、コードを削除しました。
エラーは「ORA-00904 "alias"."column_name" 無効な識別子」です。これは通常、列名が間違って入力されたか、マージの場合は結合で使用されるフィールドを更新しようとしていることを意味します。これは間違いなくそうではありません。私は4倍のチェックをしましたが、列名は正しいです。それらはすべて存在し、ステートメントの形式は他の多くの場所で使用しているものとまったく同じです。
/**
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です。