0%

sql类型不匹配

文章字数:60,阅读全文大约需要1分钟

报错 No operator matches the given name and argument type(s). You might need to add explicit type casts.
operator does not exist: character varying = integer.

传入的值和数据库类型不匹配

错误查询语句:

1
SELECT count(0) FROM TBNAME t WHERE  t.TABLE_TYPE = 1

原因:table_type的类型是字符串类型,1数值类型

修改后:

1
SELECT count(0) FROM TBNAME t WHERE  t.TABLE_TYPE = '1'

或者:

1
SELECT count(0) FROM TBNAME t WHERE  t.TABLE_TYPE =1::varchar