Hi I have the following code

SELECT entertainer_id,entertainer_groupnameFROM casestudy_entertainerINNER JOIN casestudy_availability ON casestudy_entertainer.entertainer_id = CASESTUDY_AVAILABILITY.AVAILABILITY_ENTERTAINERIDINNER JOIN casestudy_calendardates ON CASESTUDY_AVAILABILITY.AVAILIBILITY_CALENDARDATEID = casestudy_calendardates.calendar_IdWHERE entertainer_type = '&Entertainer_TYPE' AND casestudy_calendardates.calendar_date = '&Event_date'

And I don't seem to be able to figure out what its not liking when I run this. It gives me the following error

ORA-00904: "CASESTUDY_AVAILIBILITY"."AVAILIBILITY_CALENDARDATEID": invalid identifier00904. 00000 - "%s: invalid identifier"*Cause:
*Action:Error at Line: 7 Column: 4

I do have all the tables in place with all the correct rows. The only thing is I have no data as of yet, Could this possibly be the issue?

8

Best Answer


You should try the lower case for the table/column identifiers(like in from/inner join clauses):

SELECT entertainer_id,entertainer_groupnameFROM casestudy_entertainerINNER JOIN casestudy_availability ON casestudy_entertainer.entertainer_id = casestudy_availability.availability_entertaineridINNER JOIN casestudy_calendardates ON casestudy_availability.availibility_calendardateid = casestudy_calendardates.calendar_idWHERE entertainer_type = '&Entertainer_TYPE'AND casestudy_calendardates.calendar_date = '&Event_date'

When encountering the SQL Queries error 00904, it means that there is an invalid identifier in the SQL statement. This error typically occurs when referencing a column or table that does not exist in the database. To troubleshoot this issue, you need to carefully review the SQL query and check for any misspelled column or table names.

If you are certain that the column or table name is correct, ensure that you are referencing the correct schema or database. Sometimes, the error can occur if the schema is not specified, and the database is searching for the identifier in the wrong schema.

Another possible cause of this error is when using aliases for tables or columns. Ensure that the alias is correctly defined and used throughout the query. If the alias is misspelled or not properly referenced, it can result in the invalid identifier error.

To fix the invalid identifier issue, you may need to modify the SQL query by correcting the column or table name, specifying the correct schema, or fixing the alias references. It is also essential to ensure that the database schema and data are up to date and in sync with the query.

In conclusion, the SQL Queries error 00904, also known as the invalid identifier error, occurs when referencing a non-existent column or table in the SQL statement. By carefully reviewing the query, checking for spelling errors, verifying schema and alias references, and ensuring data consistency, you can troubleshoot and fix this error.

This Error is caused by a special character in one of the columns of the database table. DBA will be able to help you.

You have same tablenames in your tables while left joining.

Change tablename of one , it will work.

no data is not the issue, you won't simply get a null result. ORA-00904 indicates, that you used a column that does not exist or does not comply to the Oracle specification.

Please check for correct naming. You might be better of with shorter names or at least table aliasses to get to code more readable.

Without knowing your table structure I cannot tell you where the error is. do a describe table_name;

It would also help to have the oracle version number SELECT * FROM V$VERSION or SELECT version FROM V$INSTANCEand your client software you are using

What is interesting, Oracle gives that message not only if the name of the column is bad, but also if the name of the table/alias is bad - not defined alias, twice defined (as mentioned @PrajwalRai), error in the table name.

Old question, but maybe it helps:

sometimes you copy and paste text from a source that has a different character set ...

Type it over in sql-dev for instance and see if the error is gone

I was able to clear this error in an Oracle DB using Oracle SQL Developer by placing strings in single quotes instead of double quotes