对这段代码感到疯狂。任何人都可以让我走上正轨吗?我正在使用SQL Develope 3.1.07。感谢。
SELECT
PHA.PO_HEADER_ID,
PRLA.ATTRIBUTE1 As "REQUISITION_NUMBER",
PHA.SEGMENT1 As PO_NUMBER,
DECODE (nvl(REG.DOCUMENT_TYPE, '-'),
'APW', 'Agreement for Performance of Work',
'APWEMER', 'Agreement for Performance of Work - Emergency',
'CONS', 'Consultant',
'CONCEMER', 'Consultant - Emergency',
'DFC', 'Direct Financial Contribution',
'FELLOW', 'Fellowship',
'GENEXT', 'General External Services',
'IMPRESTCC', 'Imprest/Credit Card',
'IS', 'Internal Services',
'LOA', 'Letter of Agreement',
'TSA', 'Technical Service Agreement') as DOCUMENT_TYPE,
HAOU.NAME As BUDGET_CENTRE,
PHA.CREATION_DATE As PO_CREATION_DATE,
PHA.AUTHORIZATION_STATUS,
PHA.APPROVED_DATE,
PHA.COMMENTS,
PHA.CLOSED_DATE,
PHA.CLOSED_CODE,
PDA.PO_DISTRIBUTION_ID,
AIDA.INVOICE_ID,
AIA.INVOICE_TYPE_LOOKUP_CODE AS INVOICE_TYPE,
AIA.REMIT_TO_SUPPLIER_NAME AS SUPPLIER_NAME,
AIA.REMIT_TO_SUPPLIER_ID AS SUPPLIER_ID,
AIA.INVOICE_DATE, AIA.INVOICE_NUM,
AIA.INVOICE_AMOUNT,
AIA.INVOICE_CURRENCY_CODE AS INVOICE_CURRENCY,
AIA.GL_DATE,
AIA.PAYMENT_CURRENCY_CODE AS PAYMENT_CURRENCY,
AIA.PAYMENT_CROSS_RATE_DATE AS PAYMENT_DATE,
AIA.DESCRIPTION, AIA.EXCHANGE_DATE,
AIA.EXCHANGE_RATE,
AIA.BASE_AMOUNT AS FUNCTIONAL_CURRENCY_AMOUNT
FROM
po_headers_all pha,
po_distributions_all pda,
ap_invoice_distributions_all aida,
ap_invoices_all aia,
po_requisition_lines_all prla,
po_req_distributions_all prda,
hr.hr_all_organization_units haou,
pa.pa_projects_all ppa
LEFT JOIN
xxwrp.xxwrp_service_reg_all reg
ON
reg.po_header_id = pha.po_header_id
WHERE
1=1
AND pha.segment1 = '201251390'
AND pda.req_distribution_id = prda.distribution_id
AND prda.requisition_line_id = prla.requisition_line_id
AND pha.po_header_id = pda.po_header_id
AND pda.po_distribution_id = aida.po_distribution_id
AND aida.invoice_id = aia.invoice_id
AND pda.project_id = ppa.project_id
AND haou.organization_id=ppa.carrying_out_organization_id
AND pha.creation_date > aia.invoice_date
GROUP BY
PHA.PO_HEADER_ID, PRLA.ATTRIBUTE1, PHA.SEGMENT1, REG.DOCUMENT_TYPE, HAOU.NAME, PHA.CREATION_DATE, PHA.AUTHORIZATION_STATUS, PHA.APPROVED_DATE, PHA.COMMENTS, PHA.CLOSED_DATE, PHA.CLOSED_CODE, PDA.PO_DISTRIBUTION_ID, AIDA.INVOICE_ID, AIA.INVOICE_TYPE_LOOKUP_CODE, AIA.REMIT_TO_SUPPLIER_NAME, AIA.REMIT_TO_SUPPLIER_ID, AIA.INVOICE_DATE, AIA.INVOICE_NUM, AIA.INVOICE_AMOUNT, AIA.INVOICE_CURRENCY_CODE, AIA.GL_DATE, AIA.PAYMENT_CURRENCY_CODE, AIA.PAYMENT_CROSS_RATE_DATE, AIA.DESCRIPTION, AIA.EXCHANGE_DATE, AIA.EXCHANGE_RATE, AIA.BASE_AMOUNT
当我运行它时,它会返回此错误:
ORA-00904:“PHA”。“PO_HEADER_ID”:标识符无效 00904. 00000 - “%s:无效标识符” *原因:
*行动: Line出现错误:50列:21
答案 0 :(得分:0)
问题是你的左连接。可能缺少一列;你加入的那个。
以下是您收到的错误的详细信息: https://www.techonthenet.com/oracle/errors/ora00904.php
答案 1 :(得分:0)
问题在于将旧的Oracle语法与ANSI连接语法混合在一起;例如,假设你有这些表:
create table t1(n1 number);
create table t2(n2 number);
create table t3(n3 number);
这就是你得到的:
SQL> select *
2 from t1,t2
3 left join t3 on t3.n3 = t1.n1
4 where t1.n1 = t2.n2;
left join t3 on t3.n3 = t1.n1
*
ERROR at line 3:
ORA-00904: "T1"."N1": invalid identifier
SQL> select *
2 from t1
3 inner join t2 on t1.n1 = t2.n2
4 left join t3 on t3.n3 = t1.n1;
no rows selected