| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> How to convert raw (or long raw) to varchar2 in PL/SQL?
Hello all
I want to convert raw (or long raw) data type in varchar2 data type in PL/SQL. This must be an identity function - each source byte maps into the equal target byte. I can propose the solution, but it is too slow:
FUNCTION RAWTOCHAR
( X LONG RAW
) RETURN VARCHAR2 IS
I INTEGER; J1 INTEGER; J2 INTEGER;
J1:=ASCII(UPPER(SUBSTR(Z,I,1)));
IF 48<=J1 AND J1<=57 THEN
J1:=J1-48;
ELSE
J1:=J1-65+10;
END IF;
J2:=ASCII(UPPER(SUBSTR(Z,I+1,1)));
IF 48<=J2 AND J2<=57 THEN
J2:=J2-48;
ELSE
J2:=J2-65+10;
END IF;
Y:=Y||CHR(J1*16+J2);
I:=I+2;
Protasov Andrew
email: protasov_at_percombank.kiev.ua
Received on Tue Nov 26 1996 - 00:00:00 CST
![]() |
![]() |