File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes DB2 - case sensitive or not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DB2 - case sensitive or not" Watch "DB2 - case sensitive or not" New topic
Author

DB2 - case sensitive or not

Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi,
When I do a search in a DB2 database table using a SQL string, for example, select * from table1 where column1 like 'Abc'.
Does the select condition in the where clause (e.g., 'Abc' in the above example) case sensitive or not? If is case sensitive, then how can I select everything from the table containing abc regardless the case of the characters?


Thanks,<br />Mike
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

to avoid case sensitivity you can use a DB2 procedure in your query (example is using Oracle) like:
"select * from table where UPPER( column1 ) like UPPER( '" + string_val + "') ");
*note: UPPER is the Oracle procedure for upper case conversion, not sure what the equivalent DB2 procedure is
You can find out if the column is case sensitive by doing some test queries.
Jamie
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
You can follow Jamie's example and use UCASE instead of UPPER. UCASE is the DB2 equivalent of that function.
[ August 07, 2002: Message edited by: Bosun Bello ]

Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
HI Jamie and Bosun,
Thank you for your help. One further question:
When using select * from table1 where column1 = 'abc', the select is NOT case sensitive. Is it right?
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Mike, it is not case sensitive. Why don't you try it and see what happens?
Mike Yu
Ranch Hand

Joined: Nov 17, 2001
Posts: 175
Hi Bosun,
Thank you again. I really tried. I just wanted to make sure that it is 100% right.
Paul Misoni
Greenhorn

Joined: Jan 02, 2001
Posts: 16
You only have to be concerned about the DATA regarding case.
For reserved words and metadata it doesn't matter ('cause DB2 is going to treat those as uppercase anyways).
(Just throwing in my two cents worth)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DB2 - case sensitive or not
 
Similar Threads
Using wildcards for Select parameters
DB2 Query Batch?
Search on the tables created by ebjs are case sensitive! Why?
Problem in SQL (MySQL) select password column
How to make SELECT statement case sensitive?