I am running an oracle query in sqldeveloper:
merge into invoices c using (select CUSTOMER_ID, INVOICE_NUMBER, INVOICE_DATE from dual where INVOICE_NUMBER = '123'
and CUSTOMER_ID = '456' and INVOICE_DATE = '19-APR-12') cd
on (c.INVOICE_NUMBER = cd.INVOICE_NUMBER)
when not matched then
insert (c.CUSTOMER_ID, c.INVOICE_NUMBER, c.INVOICE_DATE)
values ('987', '654','179-APR-12')
I keep getting a RA-00904 invalid identifier for the RA-00904 INVOICE_DATE column, even though that column exists. I have verified by running the describe invoices command and then actually copying the column name:
describe invoices;
Name
----------------
CUSTOMER_ID
INVOICE_NUMBER
INVOICE_DATE
What's going on here?
RESOLUTION
Vadim and Justin are correct. I fixed the problem by replacing dual with the table name:
merge into invoices c using (select CUSTOMER_ID, INVOICE_NUMBER, INVOICE_DATE from invoices where INVOICE_NUMBER = '123'
and CUSTOMER_ID = '456' and INVOICE_DATE = '19-APR-12') cd
on (c.INVOICE_NUMBER = cd.INVOICE_NUMBER)
when not matched then
insert (c.CUSTOMER_ID, c.INVOICE_NUMBER, c.INVOICE_DATE)
values ('987', '654','179-APR-12')