一、自定义转码函数--ASCII转换为十六进制createorreplacefunctionAscToHex(sInINvarchar2)RETURNvarchar2ISsTmpv 一、自定义转码函数 --ASCII转换为十六进制 create or replace function AscToHex(sIn IN varchar2) RETURN v
一、自定义转码函数
--ASCII转换为十六进制 create or replace function AscToHex(sIn IN varchar2) RETURN varchar2 IS sTmp varchar2(4000); i integer; BEGIN i:1; stmp:; for i in 1..length(sIn) loop sTmp:sTmp||trim(to_char(ascii(substr(sIn,i,1)),XXXX)); end loop; return sTmp; END;
--十六进制转换为ASCII create or replace function HexToAsc(sIn IN varchar2) RETURN varchar2 IS sTmp varchar2(4000); i integer; x integer; BEGIN i:1; stmp:; loop exit when i>length(sIn); x:to_number(substr(sIn,i,2),XXXX); if x>128 then sTmp:sTmp||chr(to_number(substr(sIn,i,4),XXXX)); i:i4; else sTmp:sTmp||chr(to_number(substr(sIn,i,2),XXXX)); i:i2; end if; end loop; return sTmp; END;
二、