| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL function to output number as hexadecimal string?
SET ECHO off
REM NAME: TFSDC2HX.SQL
REM USAGE:"@path/tfsdec2hx"
REM ------------------------------------------------------------------------REM REQUIREMENTS:
REM ------------------------------------------------------------------------REM PURPOSE:
REM ------------------------------------------------------------------------REM EXAMPLE:
REM ------------------------------------------------------------------------REM DISCLAIMER:
REM ------------------------------------------------------------------------REM Main text of script follows:
FUNCTION hextodec (hexnum in char) RETURN number IS
x number;
digits number;
result number := 0;
current_digit char(1);
current_digit_dec number;
BEGIN
digits := length(hexnum);
for x in 1..digits loop
current_digit := SUBSTR(hexnum, x, 1);
if current_digit in ('A','B','C','D','E','F') then
current_digit_dec := ascii(current_digit) - ascii('A') +
10;
else
current_digit_dec := to_number(current_digit);
end if;
result := (result * 16) + current_digit_dec;
end loop;
return result;
END;
I hope this of any help
Regards
"The Views expressed here are my own and not necessarily those of Oracle Corporation"
Kevin P. Fleming <kfleming_at_access-laserpress.com> wrote in message
news:SGLk3.69981$Fz2.10560_at_news.rdc1.az.home.com...
> Anyone have one of these beasts already written they'd care to share?
>
Received on Mon Jul 19 1999 - 17:52:08 CDT
![]() |
![]() |