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;