【发布时间】:2011-06-03 18:44:40
【问题描述】:
我花了一天的大部分时间试图确定为什么合并语句不起作用,我开始认为问题一定是有点奇怪。
我的数据库有几十个使用合并语句的 PL/SQL 过程,但我绝对不能让一个特别工作。尽管它比所示示例大得多,但我已对其进行了精简,使其仅更新几列,但仍无法编译。
错误是'ORA-00904 "alias"."column_name" 无效标识符'。这通常意味着列名输入错误,或者在合并的情况下,您正在尝试更新连接中使用的字段。绝对不是这种情况。我已经检查了四倍,列名是正确的,它们都存在并且语句的格式与我在许多其他地方使用的格式完全相同。
/**
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 where column_name =
”时会发生什么?
标签: sql oracle oracle10g ora-00904