我在子查询中的ORA-00904: "XSRM"."RATER_PERSON_ID": invalid identifier
上获得xsrm.rater_person_id
。这是一个错误,因为如果我取出子查询和select xsrm.rater_person_id
?
select xsrm.person_id,
xsrm.member_id,
xsrm.rater_person_id,
xses.date_sent
from apex_ebs_extension.xxpay_survey_ratee_members xsrm,
apex_ebs_extension.xxpay_survey_emails_sent xses
where xsrm.reason = '$X$'
and xsrm.project_id = 1
and xses.parent_type (+) = 'R' -- Ratee member
and xses.parent_id (+) = xsrm.member_id
and 0 <
(
select sum(decode(xsa.answer, null, 1, 0))
from apex_ebs_extension.xxpay_survey_questions xsq
left outer join apex_ebs_extension.xxpay_survey_answers xsa
on xsa.question_id = xsq.question_id
and xsa.person_id = xsrm.person_id
and xsa.rater_person_id = xsrm.rater_person_id
where xsq.questionnaire_id = 1
and xsq.required_flag = 'Y'
)
这也同样失败了:
select xsrm.person_id,
xsrm.member_id,
xsrm.rater_person_id,
xses.date_sent
from apex_ebs_extension.xxpay_survey_ratee_members xsrm
left outer join apex_ebs_extension.xxpay_survey_emails_sent xses
on xses.parent_id = xsrm.member_id
and xses.parent_type = 'R' -- Ratee member
and xses.email_event_id = :p_email_event_id
where xsrm.reason = '$X$'
and xsrm.project_id = 1
and 0 <
(
select sum(decode(xsa.answer, null, 1, 0))
from apex_ebs_extension.xxpay_survey_questions xsq
left outer join apex_ebs_extension.xxpay_survey_answers xsa
on xsa.question_id = xsq.question_id
and xsa.person_id = xsrm.person_id
and xsa.rater_person_id = xsrm.rater_person_id
where xsq.questionnaire_id = 1
and xsq.required_flag = 'Y'
)
我最近才开始摆弄ansi sql而不是Oracle外连接。
apex_ebs_extension.xxpay_survey_ratee_members
结构:
"member_id","project_id","ratee_group_id","person_id","rater_person_id","verifier_person_id","reason","rater_level","position_number","verifier_level"
答案 0 :(得分:1)
在Oracle 11g中使用我自己的表测试了这个并得到了同样的错误。显然,Oracle无法在子查询中的连接的 ON子句中使用外部查询中的列。
这肯定对我来说是一个错误,因为这是一个相关的子查询,Oracle似乎没有完全对待它。