使用 LIKE 子句在 AS/400 上查询的问题

发布于 2024-11-25 04:20:31 字数 726 浏览 2 评论 0原文

我们使用 Hibernate 连接到 AS/400。我们在 AS/400 上查询时遇到问题 与 LIKE 子句。

显示以下错误:

java.sql.SQLException:[SQL0131] LIKE 操作数不兼容或无效

我的查询是由 Hibernate 自动生成的:

select tab_parame0_.C1IMCD as C1_560_, tab_parame0_.C1NINB as C2_560_,
tab_parame0_.C1JXCD as C3_560_, tab_parame0_.C1HLTX as C4_560_, tab_parame0_.C1HMTX as C5_560_,
tab_parame0_.C1HDST as C6_560_, tab_parame0_.C1NGNB as C7_560_, tab_parame0_.C1NJNB as C8_560_,
tab_parame0_.C1NFNB as C9_560_, tab_parame0_.C1NHNB as C10_560_, tab_parame0_.C1HCST as C11_560_
from RYC1REP tab_parame0_
where lower(tab_parame0_.C1HLTX) like lower(?)
order by tab_parame0_.C1IMCD asc
fetch first 10 rows only

We are using Hibernate to connect to AS/400. We are having issues with a query on the AS/400
with the LIKE clause.

The following error is shown:

java.sql.SQLException: [SQL0131] Operands of LIKE not compatible or not valid

My query is its auto generated by Hibernate:

select tab_parame0_.C1IMCD as C1_560_, tab_parame0_.C1NINB as C2_560_,
tab_parame0_.C1JXCD as C3_560_, tab_parame0_.C1HLTX as C4_560_, tab_parame0_.C1HMTX as C5_560_,
tab_parame0_.C1HDST as C6_560_, tab_parame0_.C1NGNB as C7_560_, tab_parame0_.C1NJNB as C8_560_,
tab_parame0_.C1NFNB as C9_560_, tab_parame0_.C1NHNB as C10_560_, tab_parame0_.C1HCST as C11_560_
from RYC1REP tab_parame0_
where lower(tab_parame0_.C1HLTX) like lower(?)
order by tab_parame0_.C1IMCD asc
fetch first 10 rows only

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

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

发布评论

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

评论(1

〗斷ホ乔殘χμё〖 2024-12-02 04:20:31

SQL0131 指示类型不匹配。

tab_parame0_.C1HLTX 是什么数据类型?您的查询参数是什么数据类型?

请附上您的 HQL/JPQL 查询源代码以进行比较

您可能必须设置 SQL 跟踪才能准确查看 AS/400 正在接收的内容。

请参阅 如何使用工具箱?


我建议您在源查询中将 LIKE LOWER(:parameter) 更改为 LIKE :parameter 并使用 .toLowerCase() 当您设置参数并查看其工作原理。

SQL0131 indicates a type mismatch.

What datatype is tab_parame0_.C1HLTX? What datatype is your query parameter?

Please include your HQL/JPQL query source code for comparison.

You may have to set up an SQL trace to see exactly what the AS/400 is receiving.

See How do I obtain trace information from my Java program using the Toolbox?


I recommend you change LIKE LOWER(:parameter) to LIKE :parameter in your source query and use .toLowerCase() when you set the parameter and see how that works.

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