不区分大小写和重音的“like”;比较 Oracle 而不改变 Oracle 上的会话

发布于 2024-09-24 03:01:03 字数 349 浏览 3 评论 0原文

我需要能够跨多种语言执行“类似”查询,以便对元音变音、a 和 A 进行相同的处理,等等。我使用的是 10gr2 的 oracle,我无法更改会话。

我一直在尝试类似的事情

nls_upper(col_name,'NLS_SORT=BINARY_AI') like nls_upper('%fur%','NLS_SORT=BINARY_AI')

,但我没有任何快乐。无论我做什么,nls_upper 的结果似乎都会保留 U 上的变音符号。

有什么我可以使用的函数或运算符吗?理想情况下,它还会将德语 eszett(看起来像 B 的有趣字符)转换为双 S。

感谢您的帮助!

I need to be able to do 'like' queries across several languages, so that a umlaut, a and A are treated the same and so on. I'm on 10gr2 of oracle and I can't alter the session.

I've been trying things like

nls_upper(col_name,'NLS_SORT=BINARY_AI') like nls_upper('%fur%','NLS_SORT=BINARY_AI')

but I'm not having any joy. Whatever I do, the result of nls_upper seems to preserve the umlauts on U for example.

Is there any function or operator I can use? Ideally, it would also convert the German eszett - that funny characted that looks like a B - into double S.

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

长发绾君心 2024-10-01 03:01:03

所以实际上,最好的解决方案似乎是将两个字符串都转换为 US7ASCII,因为这样会去掉所有重音。所以我可以这样做:

upper(convert(col_name, 'US7ASCII')) 像 upper(convert('%okopla%','US7ASCII'))

我发现的唯一问题是德语 eszett 被转换为 ?。所以我只是要查看我的搜索词,如果它包含一个有趣的 B,那么我将使用 Gary 的 NLS_UPPER ('große', 'NLS_SORT = XGerman'),否则我将直接转换为ASCII。这有点笨拙,但我们只需要涵盖英语、法语和德语,所以我认为就可以了..

感谢您的帮助

So actually it seems like the best solution is to convert both string to US7ASCII, as that strips out all accents. So I can do:

upper(convert(col_name, 'US7ASCII')) like upper(convert('%okopla%','US7ASCII'))

The only wrinkle I've found is that the German eszett gets converted to ?. So I'm just going to look in my search term and if it contains a funny B, then I'm going to use Gary's NLS_UPPER ('große', 'NLS_SORT = XGerman'), otherwise I'll just do the conversion to ASCII. It's a little kludgy, but we only have to cover english, french and german, so I think it will be OK..

Thanks for your help

零度° 2024-10-01 03:01:03

根据 Oracle 文档,您需要将 NLS_COMP=LINGUISTIC 和 NLS_SORT=XGERMAN_AI 指定为元音变音且 Eszett 不敏感。我想您必须使用 replace() 手动替换 Eszetts。

According to Oracle documentation, you need to specify both NLS_COMP=LINGUISTIC and NLS_SORT=XGERMAN_AI to be both umlaut and Eszett insensitive. I guess you must replace Eszetts by hand, with a replace().

中性美 2024-10-01 03:01:03

这符合要求吗?

select case when NLS_UPPER ('große', 'NLS_SORT = XGerman') 
                     like '%SS%' then 'YES' else 'no' end match
from dual;

如果没有,您必须稍微详细说明一下要求。

Does this fit the bill ?

select case when NLS_UPPER ('große', 'NLS_SORT = XGerman') 
                     like '%SS%' then 'YES' else 'no' end match
from dual;

If not, you have to elaborate the requirements a bit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文