julian julian - 5 months ago 74
Java Question

UCASE and UPPER sql functions

I am trying to do the following query:

String query = "SELECT * FROM EMP WHERE UCASE(LAST_NAME) ";
query += "LIKE '" + lastName.toUpperCase() + "%'";


in an example of usage of an servlet to access to a database
But I am getting the error message:

Excepcion java.sql.SQLSyntaxErrorException: ORA-00904: "UCASE": invalid identifier


On the other hand, when I use the UPPER sql function, the example works but the results do not show the values of the LASTNAME column in uppercase. I do not understand what happens.

Answer

You're just comparing the upper case values, but you're selecting the actual values with select *