Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I have ORA-00904 even when the column is present?

I see an error while executing hibernate sql query.

java.sql.SQLException: ORA-00904: "table_name"."column_name": invalid identifier

When I open up the table in sqldeveloper, the column is present.

The error is only happening in PROD, not in DEV.

What should I check?

like image 965
Victor Avatar asked Apr 19 '11 21:04

Victor


People also ask

How do I resolve ORA 00904?

Ora-00904 Error Message “Invalid Identifier” This error is most common when querying a SELECT statement. To resolve this error, first check to make sure the column name being referenced exists. If it does not exist, you must create one before attempting to execute an SQL statement with the column.

Why pass is an invalid identifier?

This error occurs when your column name not as same as you are writing in your query . and avoid to give column names which are Keyword of oracle , Group this cant be your column name or table name.

What does column (+) mean in Oracle?

The plus sign is Oracle syntax for an outer join. There isn't a minus operator for joins. An outer join means return all rows from one table. Also return the rows from the outer joined where there's a match on the join key. If there's no matching row, return null.

What is column ambiguously defined in SQL?

The ambiguous column error message indicates that you have joined two (or more) columns in your query which share the same column name. The proper way to solve this is to give each table in the query an alias and then prefix all column references with the appropriate alias.


2 Answers

ORA-00904-invalid identifier errors are frequently caused by case-sensitivity issues. Normally, Oracle tables and columns are not case sensitive and cannot contain punctuation marks and spaces. But if you use double quotes to create a quoted identifier, that identifier must always be referenced with double quotes and with the correct case. For example:

create table bad_design("goodLuckSelectingThisColumn  " number); 
like image 135
Jon Heller Avatar answered Oct 19 '22 00:10

Jon Heller


Oracle will throw ORA-00904 if executing user does not have proper permissions on objects involved in the query.

like image 45
vls Avatar answered Oct 19 '22 02:10

vls