I have a query just like this:
SELECT DISTINCT name
FROM table
WHERE name COLLATE BINARY_AI LIKE '%ög%' ESCAPE '\';
The expected behavior would be that it returns names containing ög, like:
Högendorf
But, for example, also names containing just og, like:
Vogel
However, executing this query doesn't deliver a single result. For reference, the data type of name is CHAR(30)
If I slightly change it to use '%og%' instead:
SELECT DISTINCT name
FROM table
WHERE name COLLATE BINARY_AI LIKE '%og%' ESCAPE '\';
It suddenly works and delivers the results as expected.
It also does so if I keep the '%ög%' but remove the ESCAPE '\' part of the query
SELECT DISTINCT name
FROM table
WHERE name COLLATE BINARY_AI LIKE '%ög%';
If I remove the COLLATE BINARY_AI but leave the ESCAPE '\' instead, it works, but it doesn't find results like Vogel
And if I add a second COLLATE BINARY_AI to the '%ög%', it also doesn't return any results at all.
Why does this happen, and how could I fix this so I could keep the ESCAPE function?
Yep, that's not right!
This is fixed in the Oracle Database 23c Free release:
If you need a fix for this, speak with support.