Abhijit Sonawane
Abhijit Sonawane

Reputation: 1

java.sql.SQLSyntaxErrorException: ORA-00904: "columnName": invalid identifier

when I open SQL developer same column is exists with the exact same name. And it's happening in some of UAT and prod DB but working in some UAT database.

Please help me

Also please explain the difference between the following exception

  1. ORA-00904: "columnName": invalid identifier
  2. ORA-00904: "tableName"."columnName": invalid identifier

Upvotes: 0

Views: 2240

Answers (1)

Littlefoot
Littlefoot

Reputation: 142720

Mind letter case.

By default, names of all objects in Oracle are stored in uppercase, but you can reference them using any case you want. For example:

SQL> create table test (id number);

Table created.

SQL> insert into test (ID) values (1);

1 row created.

SQL> select iD from TeST;

        ID
----------
         1

SQL> select ID from test;

        ID
----------
         1

But, if you used double quotes and mixed case, then you have to use double quotes and exactly the same letter case, always:

SQL> create table "Test" ("iD" number);

Table created.

SQL> insert into test (id) values (1);
insert into test (id) values (1)
            *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> insert into "Test" (ID) values (1);
insert into "Test" (ID) values (1)
                    *
ERROR at line 1:
ORA-00904: "ID": invalid identifier


SQL> insert into "Test" ("ID") values (1);
insert into "Test" ("ID") values (1)
                    *
ERROR at line 1:
ORA-00904: "ID": invalid identifier


SQL> insert into "Test" ("iD") values (1);

1 row created.

SQL>

As of two errors you posted: they are the same. The only difference is that the 2nd shows owner (schema) name along with column name. Note that it is NOT database name (as "DB_Name" suggests); in Oracle, database is something different. If you're trying to make a relation between Oracle and some other DBMS', then what is a "database" there is "user" (or "schema") in Oracle.

Apart from that, no difference. ORA-00904 means that you're referencing a column which doesn't exist in that table. Again: mind letter case.

Upvotes: 1

Related Questions