*
The moose likes JDBC and the fly likes UPPERing in a prepared statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

UPPERing in a prepared statement

Ali Ekber
Ranch Hand

Joined: Jun 12, 2005
Posts: 41
I need to upper a search criteria in the WHERE clause in a prepared statement. It is something like this:

... WHERE name=UPPER(?);

But it doesn't work. Is it possible to do UPPER in prepared statement, with a different syntax? Thx.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

or you could just do it in Java when setting the String value. Either is OK, but personally I like Java in the is case as it reduces the intelligence required in the SQL statement.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
What do you mean by it doesn't work? Error or it doesn't match records like you expect?

Does the sql work when you run it outside java? What database are you using?
Ali Ekber
Ranch Hand

Joined: Jun 12, 2005
Posts: 41
Here is error message when I run my code:
[IBM][CLI Driver][DB2/AIX64] SQL0418N A statement contains a use of a parameter marker that is not valid. SQLSTATE=42610

Unfortunately, I don't have the luxury to upper case it before I send in the search criteria.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
Did you google on your error?

One google hit I found, don't know if it will help: SQL0418N error: Untyped parameter markers cannot be used in some cases???
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Duplicate conversations, Im closing this copy.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: UPPERing in a prepared statement