900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > pg/oracle数据库ascii码转字符串 自定义函数

pg/oracle数据库ascii码转字符串 自定义函数

时间:2020-07-17 16:14:18

相关推荐

pg/oracle数据库ascii码转字符串 自定义函数

pg ascii码转字符串函数

传进来一个由ascii码拼接的字符串,在数据库中转换成字符串

CREATE OR REPLACE FUNCTION dc_bill.f_xdo_to_assii(p_str character varying)RETURNS character varyingLANGUAGE plpgsqlAS $function$declare resul varchar='';--定义返回结果init Integer ;--定义 循环strLength Integer;--定义字符串长度beginIF length(p_str)>0 thenstrLength :=length(p_str)-length(replace(p_str,',',''))+1;--计算字符串长度FOR i in 1..strLength loopinit=split_part(p_str,',',i);--拆分字符resul:=resul||chr(init);--ascii转字符串后拼接成结果end loop;return resul;end if;return resul;end; $function$;

oracle ascii码转字符串函数

CREATE OR REPLACE FUNCTION DC_BILL.f_xdo_to_assii(p_str varchar)RETURN varchar ASresul varchar2(50):='';init varchar2(50);strLength NUMBER;BEGINIF length(p_str)>0 thenstrLength :=length(p_str)-length(replace(p_str,',',''))+1;FOR i IN 1..strLength LOOPinit := chr(REGEXP_SUBSTR (p_str, '[^,]+', 1,i));resul :=RESUL||init;END LOOP;RETURN resul;END IF;RETURN resul;END;

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。