Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

oracle sql developer: 00904. 00000 - "%s: invalid identifier". Where is my fault?

I am trying find my fault. I am getting this error message:

SQL-Fehler: ORA-00904: "S1"."PARTNO": ungültiger Bezeichner 00904. 00000 - "%s: invalid identifier"

I have checked my database and all tables exist.

Here is my sql code:

select s1.*
 , p.city as "Produktionsort" 
 , p.partname
from (select count(s.partno) as "Anzahl_Produktarten"
        , s.partno as "Partno" 
      from company.supp_part_job s 
      group by s.partno ) s1
 , company.part p 
where s1.partno IN (select p1.partno from company.part p1 where p1.city != 'London') 
   and p.partno = s1.partno 
group by s1.partno
like image 834
user3617496 Avatar asked May 08 '14 17:05

user3617496


People also ask

How do I fix an invalid identifier in Oracle?

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.

Where is error in SQL Developer?

control-shift-L should open the log(s) for you. this will by default be the messages log, but if you create the item that is creating the error the Compiler Log will show up (for me the box shows up in the bottom middle left).

What is identifier in SQL Developer?

An SQL identifier is the name of a database object. The following objects are examples of SQL identifiers: Parts of the database schema such as tables, columns, views, indexes, synonyms, and stored procedure names. Dynamic IBM® Informix® ESQL/C structures such as cursors and statement IDs.

What is identifier in Oracle SQL?

An identifier is the representation within the language of items created by the user, as opposed to language keywords or commands. Some identifiers stand for dictionary objects, which are the objects you create- such as tables, views, indexes, columns, and constraints- that are stored in a database.


2 Answers

Because you aliased in the inner select (s1) partno as "Partno" you must refer to it as case sensitive in the outer query:

select s1.*
 , p.city as "Produktionsort" 
 , p.partname
from (select count(s.partno) as "Anzahl_Produktarten"
        , s.partno as "Partno" 
      from company.supp_part_job s 
      group by s.partno ) s1
 , company.part p 
where s1."Partno" IN (select p1.partno from company.part p1 where p1.city != 'London') 
   and p.partno = s1."Partno" 
group by s1."Partno"
like image 149
A.B.Cade Avatar answered Jan 06 '23 01:01

A.B.Cade


If you put double quotes around a column name, it will make it case sensitive. So I would think this line:

s.partno as "Partno" 

is creating a case-sensitive s1."Partno" but the where clause is looking for s1.partno. Try removing the double quotes from your column aliases.

like image 37
Glenn Avatar answered Jan 06 '23 01:01

Glenn