Connecting Tech Pros Worldwide Forums | Help | Site Map

Overriding database collation in queries for LIKE operators

Jon.Hakkinen@gmail.com
Guest
 
Posts: n/a
#1: Nov 5 '08
Hi all,

In SQL Server I can use the COLLATE clause to sort, compare(=) and do
LIKE comparisons in queries, overiding the server collation. For
instance I can write a query like
select * from T where (someStringCol COLLATE Latin1_General_CI_AI
LIKE '%Some Text%')

DB2 provides the COLLATION_KEY_BIT function, which will work fine for
sorting and "=" comparisons, but obviously not for "LIKE", as it
returns a key.
Is there any way I can do for instance case insensitive or accent
insensitive searches in DB2 when the database collation is case/accent
sensitive? (Without using to_upper, etc)


thanks!



Serge Rielau
Guest
 
Posts: n/a
#2: Nov 6 '08

re: Overriding database collation in queries for LIKE operators


Jon.Hakkinen@gmail.com wrote:
Quote:
Hi all,
>
In SQL Server I can use the COLLATE clause to sort, compare(=) and do
LIKE comparisons in queries, overiding the server collation. For
instance I can write a query like
select * from T where (someStringCol COLLATE Latin1_General_CI_AI
LIKE '%Some Text%')
>
DB2 provides the COLLATION_KEY_BIT function, which will work fine for
sorting and "=" comparisons, but obviously not for "LIKE", as it
returns a key.
Is there any way I can do for instance case insensitive or accent
insensitive searches in DB2 when the database collation is case/accent
sensitive? (Without using to_upper, etc)
>
Not built-in. You can use the libraries here:
www.ibm.com/software/globalization/icu/index.jsp
To roll your own.
I while ago I tinkered with them a bit. If you send me an email I'll
gladly sent you as-is code to get you jump-started.

I'd also be interested in your usage. The need for "session level
collation" is highly contested. Any input welcome.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Closed Thread