Questions tagged [ora-00904]

Invalid column name. Cause: You tried to execute an SQL statement that included an invalid column name or the column name is missing.

Cause: The column name entered is either missing or invalid.

Action: Rewrite your SQL to include a valid column name. To be a valid column name the following criteria must be met:

  • The column name must begin with a letter.
  • The column name can not be longer than 30 characters.
  • The column name must be made up of alphanumeric characters or the following special characters: $, _, and #. If the column name uses any other characters, it must be enclosed in double quotation marks.
  • The column name can not be a reserved word.
168 questions
113
votes
14 answers

ORA-00904: invalid identifier

I tried to write the following inner join query using an Oracle database: SELECT Employee.EMPLID as EmpID, Employee.FIRST_NAME AS Name, Team.DEPARTMENT_CODE AS TeamID, Team.Department_Name AS teamname FROM…
Navaneethan
  • 2,125
  • 6
  • 22
  • 32
72
votes
5 answers

Using an Alias in a WHERE clause

I have a query which is meant to show me any rows in table A which have not been updated recently enough. (Each row should be updated within 2 months after "month_no".): SELECT A.identifier , A.name , TO_NUMBER(DECODE( A.month_no …
JPLemme
  • 4,374
  • 6
  • 31
  • 35
67
votes
11 answers

How to use BOOLEAN type in SELECT statement

I have a PL/SQL function with BOOLEAN in parameter: function get_something(name in varchar2, ignore_notfound in boolean); This function is a part of 3rd party tool, I cannot change this. I would like to use this function inside a SELECT statement…
Ula Krukar
  • 12,549
  • 20
  • 51
  • 65
39
votes
6 answers

Using 'case expression column' in where clause

SELECT ename , job , CASE deptno WHEN 10 THEN 'ACCOUNTS' WHEN 20 THEN 'SALES' ELSE 'UNKNOWN' END AS department FROM emp /* !!! */ WHERE department = 'SALES' This fails: ORA-00904:…
EugeneP
  • 391
  • 1
  • 3
  • 3
38
votes
14 answers

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…
Victor
  • 16,609
  • 71
  • 229
  • 409
28
votes
2 answers

Oracle subquery does not see the variable from the outer block 2 levels up

I'd like to get in one query a post and the first comment associated with the post. Here is how I do it in PostgreSQL: SELECT p.post_id, (select * from (select comment_body from comments where post_id = p.post_id order by created_date asc)…
user248789
  • 283
  • 1
  • 3
  • 5
20
votes
3 answers

"date" as a column name

I have a table called calendars. One of its columns is named 'date' When I want to select the date column it gives error ORA-01747 namely invalid table.column. select date from calendars I guess this happens because 'date' is a reserved word for…
bonsvr
  • 2,262
  • 5
  • 22
  • 33
17
votes
2 answers

Use a calculated field in the where clause

Is there a way to use a calculated field in the where clause? I want to do something like SELECT a, b, a+b as TOTAL FROM ( select 7 as a, 8 as b FROM DUAL UNION ALL select 8 as a, 8 as b FROM DUAL UNION ALL select 0 as a, 0 as b FROM…
Luc M
  • 16,630
  • 26
  • 74
  • 89
8
votes
2 answers

ORA 00904 Error:Invalid Identifier

I have installed Oracle 10g in my virtual XP and created a table using create table reg1 ( fname varchar2(30), lname varchar2(30), addr varchar2(30), mail varchar2(30), occu varchar2(30), uname varchar2(30), passwd varchar2(30) ); and…
Mistu4u
  • 5,132
  • 15
  • 53
  • 91
6
votes
4 answers

Weird Oracle SQL "Invalid Identifier" error

Can anyone help me figure out why I get an error on cms.CRIME_ID: invalid identifier select c.criminal_id, c.first, c.last, cms.CRIME_ID, cc.crime_code, cc.fine_amount from criminals c join crimes cms on c.criminal_id = cms.criminal_id join…
JohnQPublic
  • 73
  • 1
  • 1
  • 5
6
votes
3 answers

plsql oracle check in constraint error

Im getting this error: ORA-00904: "M": invalid identifier --> if I put ('M','F') //single quotation i got this error message: PLS-00103: Encountered the symbol "M" when expecting one of the following: * & = - + ; < / > at in is mod remainder not…
Mariya
  • 847
  • 1
  • 9
  • 25
5
votes
2 answers

Hibernate native SQL error

I am trying to execute sql native query using hibernate 3.3.2.GA. I have following query. session.createSQLQuery("SELECT {dept1.*}, {dept2.*} FROM Dept d1, Dept d2 WHERE d1.deptId = d2.deptId"). addEntity("dept1",com.test.pojo.Dept.class). …
Neel
  • 71
  • 1
  • 1
  • 2
4
votes
6 answers

How to reuse dynamic columns in an Oracle SQL statement?

I try to reuse some columns that I calculate dynamically in Oracle SQL, something like SELECT A*2 AS P, P+5 AS Q FROM tablename Where 'tablename' has a column called 'A', but no other colums. This gives me an ORA-00904: "P": invalid…
BlackShift
  • 2,296
  • 2
  • 19
  • 27
4
votes
4 answers

Oracle SQL - Help using Case in a Select Statement

CREATE TABLE student_totalexp2 nologging compress AS SELECT /*+parallel(a,4)*/ DISTINCT a.member_sk, CASE WHEN b.end_date IS NULL THEN SYSDATE - MIN(TO_DATE(b.start_date,'yyyymm')) ELSE …
AME
  • 5,234
  • 23
  • 71
  • 81
4
votes
2 answers

How can I get "ORA-00904: : invalid identifier" from a valid package?

I have a procedure that is valid and has in it an insert..select statement. Now there is a case where execution of this procedure produces "ORA-00904: : invalid identifier" error from this statement. How is that even theoretically possible? There…
jva
  • 2,797
  • 1
  • 26
  • 41
1
2 3
11 12