John Pen
John Pen

Reputation: 13

ORA-00904 Error

I'm using JDBC to access a database and I'm basically querying by calling a String.

Here is my table book_table:

| title | book no. | author_first | author_last |

The cat, 0, Tim, Joe
The dog, 1, John, Soe
The mouse, 2, Josh, Moe

And here is the SQL statement I am querying with:

"select title from book_table where author_first like '%tim%' and author_last like '%joe%'";

I keep getting the error exception in Java: ORA-00904: "author_last": invalid identifier"

Any clue what I'm doing wrong?

Upvotes: 0

Views: 264

Answers (1)

Kamal Kunjapur
Kamal Kunjapur

Reputation: 8840

It would be very likely that you may have used double quotes while creating the DDL for the book_table.

From the error it means that there is no such column as author_first

The names used in database should be working fine and that uppercase and lowercase could be very well be ignored if you would have not used double quotes.

 create table book_table(title varchar2(100)); 
 create table BOOK_TABLE(TITLE varchar2(100));

In both the cases

  select * from book_table where title like '%mytitle%'; 

should be working fine.

However if you would have used double quotes, then you would have to use the exact cases while performing sql operations.

create table "BOOK_TABLE"("Title" varchar2(100));

In this case

select * from book_table where title like '%mytitle%'

would not work

You have to make use of

select * from book_table where "Title" like '%mytitle%';

I'd suggest dropping the table and recreating them without double quotes and see if that solves it.

Upvotes: 2

Related Questions