问题现象

函数 lpad、rpad 不支持 length 函数运算改写。

解决方法

 业务要求 1:保持 9 位,不足位数前面补 0。

如:1234,结果:000001234。

select lpad(GH_FLAG,9-length(GH_FLAG),'0') from

ics.ASSE_BILL_ITEM_RESULT_4;

目前不支持这种语法,改写为:

select left('000000000',9-length(GH_FLAG))||GH_FLAG from

ics.ASSE_BILL_ITEM_RESULT_4;

 业务要求 2:只显示手机号前两位和姓名的第一个字符,其它以*代替。

测试表:

insert into t_01 values('13512345678','赵子龙');

1. 客户使用的是 length(phone)-1,这里用户理解有误,以为是需要补

length(phone)-1 个*,length 函数后有-1,直接报错了:

gbase> select rpad(left(phone,7),length(phone)-1,'*') as phone from t_01;

ERROR 1708 (HY000): [192.168.3.26:5050](GBA-02EX-0005) Failed to query

in gnode:

DETAIL: Query failed.

CAUSE:(GBA-01EX-700) The query includes syntax that is not supported by the

Express engine. Either restructure the query with supported syntax, or enable the

GBase Query Path in the configuration file to execute the query with reduced

performance.

SQL: SELECT /*192.168.3.25_13_32_2017-02-26_22:24:31*/ /*+ TID('79') */

rpad(left(`testdb.t_01`.`phone`, 7), (length(`testdb.t_01`.`phone`) - 1), '*') AS

`phone` FROM `testdb`.`

2. 将-1 去除,汉字后的*显示个数也不正确:

gbase> select phone,name,

-> rpad(left(phone,7),length(phone),'*') as phone,

-> rpad(left(name,1),length(name),'*') as name

-> from t_01;

+-------------+-----------+-------------+-------------+

| phone | name | phone | name |

+-------------+-----------+-------------+-------------+

| 13512345678 | 赵子龙 | 1351234**** | 赵******** |

+-------------+-----------+-------------+-------------+

Phone:后 4 位为*,正确。

name: 后 2 位应为*,因为 length 取的是字节数所以变成了 8 个*。

3. 改为 character_length,直接报错了,按研发的解释,目前 rpad 函数中不支持

使用 character_length。

gbase> select rpad(left(name,1),character_length(name),'*') as name from

t_01;

ERROR 1708 (HY000): [192.168.3.26:5050](GBA-02EX-0005) Failed to query in

gnode:

DETAIL: Query failed.

CAUSE:(GBA-01EX-700) The query includes syntax that is not supported by the

Express engine. Either restructure the query with supported syntax, or enable the

GBase Query Path in the configuration file to execute the query with reduced

performance.

SQL: SELECT /*192.168.3.25_13_26_2017-02-26_22:20:13*/ /*+ TID('76') */

rpad(left(`testdb.t_01`.`name`, 1), char_length(`testdb.t_01`.`name`), '*') AS

`name` FROM `testdb`.`t_01_n

4. 最终采用的方法是自定义一个函数取*个数再与显示字符拼接的方法解决此问

题:

delimiter $$

drop function if exists testdb.f_getstar $$

CREATE FUNCTION testdb.f_getstar(n INT)

RETURNS VARCHAR(100)

BEGIN

DECLARE i INT DEFAULT 0;

DECLARE s VARCHAR(100) DEFAULT '';

myloop: LOOP

SET i = i+1;

SET s = CONCAT(s, '*');

IF i>=n THEN LEAVE myloop;

END IF;

END LOOP myloop;

RETURN s;

END$$

delimiter ;

5. 测试结果:

gbase> select phone,name,

-> left(a.phone,2)||testdb.f_getstar(length(a.phone)-2) as

phone,

-> left(a.name,1)||testdb.f_getstar(CHARACTER_LENGTH(a.name)-

1) as name

-> from testdb.t_01 a ;

+-------------+-----------+-------------+-------+

| phone | name | phone | name |

+-------------+-----------+-------------+-------+

| 13512345678 | 赵子龙 | 13********* | 赵** |

GBASE 8A v953报错集锦34--lpad、rpad 不支持 length 函数运算改写相关推荐

  1. GBASE 8A v953报错集锦56--Hadoop 加载失败问题

    问题现象 Hadoop 升级并新增了 kerberos 认证功能,执行从 hadoop 加载数据时报错: 执行 Load data infile 'hdp://-'into table -报错: I/ ...

  2. django2.0集成xadmin0.6报错集锦

    django2.0集成xadmin0.6报错集锦 1.django2.0把from django.core.urlresolvers修改成了django.urls 报错如下: 1 2 3   File ...

  3. react+typescript报错集锦持续更新

    typescript报错集锦 错误:Import sources within a group must be alphabetized.tslint(ordered-imports) 原因:impo ...

  4. maven install 报错 source 1.5 中不支持 lambda 表达式

    maven install 报错 source 1.5 中不支持 lambda 表达式 maven-compiler-plugin 在编译的时候如果不指定jdk的版本,会默认使用jdk1.5 所以在编 ...

  5. 深圳坐标软件 SQL数据库 复制 报错 MS-DOS 功能无效 上读取失败 1(函数不正确) 恢复实践

    坐标软件 SQL数据库 复制 报错 MS-DOS 功能无效 上读取失败 1(函数不正确) 恢复实践 接到文件,立即组织进行分析工作,发现 select * from sysobjects  --系统表 ...

  6. 源码安装zabbix遇到的报错集锦

    报错1:checking for mysql_config... configure: error: MySQL library not found 解决办法:查找mysql_config #find ...

  7. oracle 10g rac数据库,oracle 10g rac安装报错集锦

    oracle 10g rac安装报错汇总 删除crs 1.      停止资源:关闭crs资源:crsctl stop resources 关闭crs:       crsctl stop crs 2 ...

  8. 【点云3D目标检测】跑通CIA-SSD过程中的一些报错集锦

    前言 本文主要是介绍了在跑通CIA-SSD系列算法过程中遇到的一些bug,下面是对CIASSD算法的一个简单的介绍. CIA-SSD其基本思想是校准单步目标检测中分类和定位两个任务,提出Confide ...

  9. matlab报错集锦,matlab编程笔记:错误集锦

    总结一些自己遇到过的使人抓狂的报错,往往是自己粗心大意造成的: 1.变量名与函数名混用 disp('jafjjaja') ??? Index exceeds matrix dimensions 原因: ...

最新文章

  1. Eclipse 官宣,要干掉 VS Code,你怎么看?
  2. ACP-PMP备考交流
  3. R开发(part2)--R语言中的数学计算
  4. 怎么用odbc连接mysql数据库连接_PowerDesigner通过ODBC来实现Mysql数据库的连接操作...
  5. discuz 不能上传头像提示can not write to the data/tmp folder
  6. 电动车式的爱情,有你有我有爱、青春不再,人生无悔!
  7. Java 和 Python 疯狂 PK,等等,请不要放弃 C 语言
  8. php百度地图地址解析失败,javascript - vue中使用百度地图 提示无法解析
  9. 2019 Flutter 心愿单
  10. 数据库发展的三个阶段及特点
  11. 温度对免疫代谢调节和癌症进展的影响
  12. 如何利用新浪博客做外链1
  13. Android--高德地图,显示地图,并定位当前的位置
  14. Python selenium淘宝抢购物品程序
  15. 计算机无纸化考试知识点,2012重庆无纸化考试《会计电算化》知识点:计算机软件...
  16. UI设计中线性图标设计总结
  17. 程序员进阶!阿里P7级别面试经验总结,深度好文
  18. PC上测试移动端网站和模拟手机浏览器
  19. 新AlphaGo首度揭秘:单机运行,4个TPU,算法更强
  20. 剑灵系统推荐加点_《剑灵》各职业练级推荐修炼加点攻略

热门文章

  1. mumu安装xposed
  2. 你不能忍受的无理需求是什么?真是感同身受
  3. 2019武大计算机学院博导名单,关于公示2020年具有硕士招生资格导师名单和2019年同时具有专业型博士招生资格导师名单的通知...
  4. 基于C语言的全国交通咨询系统模拟(设计报告+代码+运行说明)
  5. 南航金城学院计算机科学与技术怎么样,南京航空航天大学金城学院计算机科学与技术专业2016年在江苏理科高考录取最低分数线...
  6. English - when用法
  7. Visual C++ 2010中初学者常见错误、警告和问题
  8. 做自媒体视频剪辑可以当成副业来赚钱吗?
  9. 3-2 Verilog 4位行波进位加法器
  10. 通俗易懂解释拜占庭容错