使用 LIKE 子句在 AS/400 上查询的问题
我们使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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)
toLIKE :parameter
in your source query and use.toLowerCase()
when you set the parameter and see how that works.