南大通用GBase 8a数据库to_number关联报错问题处理方法

原文链接:www.gbase.cn/community/p...

更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。

问题现象

to_number和decimal列关联时报错,报错内容如下:

sql 复制代码
ERROR 1149 (42000): (GBA-02SC-1001) Data types of equivalence join relation ((to_number(`a`.`a`) = `b`.`a`)) are not supported , data types: left is DOUBLE, right is DECIMAL(22,0)

具体复现过程:

sql 复制代码
gbase> create table t_to_number_dec(a decimal(22,0));
Query OK, 0 rows affected (Elapsed: 00:00:02.04)
gbase> create table t_to_number_varchar(a varchar(10));
Query OK, 0 rows affected (Elapsed: 00:00:00.12)
gbase> insert into t_to_number_dec values (111111);
Query OK, 1 row affected (Elapsed: 00:00:00.39)
gbase> insert into t_to_number_varchar values ('111111');
Query OK, 1 row affected (Elapsed: 00:00:00.35)
gbase> select * from t_to_number_varchar a join t_to_number_dec b on to_number(a.a) = b.a;
ERROR 1149 (42000): (GBA-02SC-1001) Data types of equivalence join relation ((to_number(`a`.`a`) = `b`.`a`)) are not supported , data types: left is DOUBLE, right is DECIMAL(22,0)

解决方案:

修改gbase_to_number_str2dec为1,修改后执行情况如下:

sql 复制代码
gbase> set gbase_to_number_str2dec = 1;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)
gbase> select * from t_to_number_varchar a join t_to_number_dec b on to_number(a.a) = b.a;
+--------+--------+
| a      | a      |
+--------+--------+
| 111111 | 111111 |
+--------+--------+
1 row in set (Elapsed: 00:00:00.12)

附:gbase_to_number_str2dec参数含义:

to_number函数在处理字符串时,转换后的类型时,参数值为0时转换成double类型,参数值为1时,转换成decimal(65,30)类型。

默认值:'OFF,0

最小值:'OFF',0

最大值:ON',1

级别: global、session

原文链接:www.gbase.cn/community/p...

更多精彩内容尽在南大通用GBase技术社区,南大通用致力于成为用户最信赖的数据库产品供应商。

相关推荐
得物技术3 分钟前
MySQL单表为何别超2000万行?揭秘B+树与16KB页的生死博弈|得物技术
数据库·后端·mysql
可涵不会debug4 小时前
【IoTDB】时序数据库选型指南:工业大数据场景下的技术突围
数据库·时序数据库
ByteBlossom4 小时前
MySQL 面试场景题之如何处理 BLOB 和CLOB 数据类型?
数据库·mysql·面试
麦兜*4 小时前
MongoDB Atlas 云数据库实战:从零搭建全球多节点集群
java·数据库·spring boot·mongodb·spring·spring cloud
Slaughter信仰4 小时前
深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)第十章知识点问答(10题)
java·jvm·数据库
麦兜*4 小时前
MongoDB 在物联网(IoT)中的应用:海量时序数据处理方案
java·数据库·spring boot·物联网·mongodb·spring
-Xie-5 小时前
Mysql杂志(十六)——缓存池
数据库·mysql·缓存
七夜zippoe5 小时前
缓存与数据库一致性实战手册:从故障修复到架构演进
数据库·缓存·架构
一个天蝎座 白勺 程序猿6 小时前
Apache IoTDB(5):深度解析时序数据库 IoTDB 在 AINode 模式单机和集群的部署与实践
数据库·apache·时序数据库·iotdb·ainode