CREATE OR REPLACE FUNCTION dec2hex (N in number) RETURN varchar2 IS hexval varchar2(64); N2 number := N; digit number; hexdigit char; BEGIN while ( N2 > 0 ) loop digit := mod(N2, 16); if digit > 9 then hexdigit := chr(ascii('A') + digit - 10); else hexdigit := to_char(digit); end if; hexval := hexdigit || hexval; N2 := trunc( N2 / 16 ); end loop; return hexval; END dec2hex; / SQL> SELECT dec2hex(44978) FROM dual;
DEC2HEX(44978) -------------- AFB2
Nenhum comentário :
Postar um comentário