解决java传递参数是String类型,pgsql的numeric字段接收报错问题
2017-08-18 16:41
886 查看
postgresql对传入的参数类型匹配相当严格
如select * from user where id = #id#
假设id类型为numeric,而传入的id为string的话postgresql就会报错:
--- Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: numeric = character varying
建议:No operator matches the given name and argument type(s). You might need to add explicit type
casts.
位置:125
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: numeric = character varying
建议:No operator matches the given name and argument type(s). You might need to add explicit type
casts.
暂时想到的解决方法:
select * from user where id = cast(#id# as numeric)
如果哪位大神有更好的方法请告知!
如select * from user where id = #id#
假设id类型为numeric,而传入的id为string的话postgresql就会报错:
--- Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: numeric = character varying
建议:No operator matches the given name and argument type(s). You might need to add explicit type
casts.
位置:125
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: numeric = character varying
建议:No operator matches the given name and argument type(s). You might need to add explicit type
casts.
暂时想到的解决方法:
select * from user where id = cast(#id# as numeric)
如果哪位大神有更好的方法请告知!
相关文章推荐
- Java中String类型的参数传递问题的解析收藏--转载
- Java-String类型的参数传递问题
- 关于Java中String类型的参数传递问题
- java中String类型参数传递问题
- Java-String类型的参数传递问题
- (转载)Java String类型的参数传递问题
- Java-String类型的参数传递问题
- Java中String类型的参数传递问题的解析
- 简单谈谈Java中String类型的参数传递问题
- Java中String类型的参数传递问题的解析
- Java-String类型的参数传递问题
- 解决post请求接收数据类型为text/html时参数传递的问题
- Java-String类型的参数传递问题
- Java中String类型的参数传递问题的解析
- Java中String类型的参数传递问题的解析
- Java-String类型的参数传递问题 推荐
- Java值传递和地址传递:关于String类型和集合类型作为函数参数时传值问题的测试
- Java中String类型的参数传递问题的解析
- [Java]String类型的参数传递问题
- Java-String类型的参数传递问题