LIKE with COLLATION and ESCAPE

  • From: Martin Berger <martin.a.berger@xxxxxxxxx>
  • To: Oracle-L oracle-l <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 26 Feb 2021 20:34:28 +0100

Hi List,

Yesterday I was confronted  with an interesting question they faced.
They have some entries in a varchar2 column such as
_A, _B, _Ä, _,  A
The LIKE pattern is '\_%' ESCAPE '\'
when NLS_COMP is LINGUISTIC and  NLS_SORT is set to GERMAN_AI
this LIKE doesn't return any rows.

My suggested workaround is to use
('\_%' COLLATE GERMAN_AI ) escape '\'
But I can't explain, why this is required to make the % work as I expect.
Why  % is sensitive of the collation?

Can anyone give me a hint, please?

A simple testcase can be found at
https://livesql.oracle.com/apex/livesql/s/lfcf58k7cj18t22jeth3rz6cu

thank you,
 Martin

-- 
Martin Berger                Oracle ♠
martin.a.berger@xxxxxxxxx @martinberx <https://twitter.com/martinberx>
^∆x      http://berxblog.blogspot.com

Other related posts: