postgresql查询时报类型错误解决办法

### The error occurred while setting parameters
### SQL: SELECT dd.detail_id, dd.remind_time FROM dic_tab_map dtm LEFT JOIN dic_spot ds ON dtm.dic_id = ds.dic_id LEFT JOIN dic_detail dd ON dtm.dic_id = dd.dic_id WHERE ds.dept_id = ? AND dtm.table_name = ? AND dtm.column_bus_name = ?
### Cause: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
  建议:No operator matches the given name and argument types. You might need to add explicit type casts.
  位置:173
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
  建议:No operator matches the given name and argument types. You might need to add explicit type casts.
  位置:173
	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:91)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
	at com.sun.proxy.$Proxy138.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89)
	at com.sun.proxy.$Proxy235.getDicByTableMap(Unknown Source)
	at com.ruoyi.data.service.DicJobService.getDicByTableMap(DicJobService.java:26)
	at com.ruoyi.data.job.DataGet.getZfbaData(DataGet.java:38)
	... 6 more
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying
  建议:No operator matches the given name and argument types. You might need to add explicit type casts.
  位置:173
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)

解决:

使用cast( xx as xx)进行类型转换

select
	dd.detail_id ,
	dd.remind_time
from
	dic_tab_map dtm
left join dic_spot ds on
	dtm.dic_id = ds.dic_id
left join dic_detail dd on
	dtm.dic_id = dd.dic_id
where
	ds.dept_id = cast('130123' as bigint)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值