栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

HINT: No operator matches the given name and argument types. You might need to add explicit type

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

HINT: No operator matches the given name and argument types. You might need to add explicit type

postgres=# create table test(t varchar(32));
CREATE TABLE
postgres=# insert into test values('1');
INSERT 0 1
postgres=# insert into test values('2');
INSERT 0 1
postgres=# insert into test values('3');
INSERT 0 1
postgres=# select * from test where t=2;
ERROR:  operator does not exist: character varying = integer
LINE 1: select * from test where t=2;
                                  ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=# select * from test where t='2';
 2

postgres=# insert into test values(4);
INSERT 0 1
postgres=# select * from test where t=4;
ERROR:  operator does not exist: character varying = integer
LINE 1: select * from test where t=4;
                                  ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=# 
postgres=# select * from test where t=cast(2 as VARCHAR);
 2

postgres=# create cast(integer as varchar) with inout as implicit;
CREATE CAST
postgres=# create cast(varchar as integer) with inout as implicit;
CREATE CAST
postgres=# select * from test where t=4;
 4

postgres=# create cast(bigint as varchar) with inout as implicit;
CREATE CAST
postgres=# create cast(varchar as bigint) with inout as implicit;
CREATE CAST
postgres=# select * from test where t='2';
 2

postgres=# select * from test where t=2;
ERROR:  operator is not unique: character varying = integer
LINE 1: select * from test where t=2;
                                  ^
HINT:  Could not choose a best candidate operator. You might need to add explicit type casts.
postgres=# select * from test where t=4;
ERROR:  operator is not unique: character varying = integer
LINE 1: select * from test where t=4;
                                  ^
HINT:  Could not choose a best candidate operator. You might need to add explicit type casts.
postgres=# create cast(integer as varchar) with inout as implicit;
ERROR:  cast from type integer to type character varying already exists
postgres=# drop cast(bigint as varchar);
DROP CAST
postgres=# drop cast(varchar as bigint);
DROP CAST
postgres=# select * from test where t=4;
 4

postgres=# drop cast(varchar asdrop cast(varchar as integer) ;
postgres(# 
postgres(# ^C
postgres=# drop cast(varchar as integer);
DROP CAST
postgres=# select * from test where t=4;
ERROR:  operator does not exist: character varying = integer
LINE 1: select * from test where t=4;
                                  ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=# select * from test where t=2;
ERROR:  operator does not exist: character varying = integer
LINE 1: select * from test where t=2;
                                  ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
postgres=# create cast(integer as varchar) with inout as implicit;
ERROR:  cast from type integer to type character varying already exists
postgres=# create cast(varchar as integer) with inout as implicit;
CREATE CAST
postgres=# select * from test where t=2;
 2

postgres=# select * from test where t=4;
 4
 

PostgreSQL 自定义自动类型转换(CAST)-阿里云开发者社区

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1013601.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号