Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: get integers in hex-format
Here's a little function that converts a number to
an hexadecimal string:
create or replace function to_char_hex (num integer) return varchar2 is
result varchar2(100);
no integer := num;
quot integer;
remaind integer;
function to_char_hex_digit (num integer) return varchar2 is
begin
if num < 10 then
return to_char(num);
else
return CHR(ASCII('A') + (num - 10));
end if;
end;
begin
if num is null then
return null;
end if;
if num = 0 then
return '0';
end if;
while (no > 0) loop
quot := trunc(no/16);
remaind := no MOD 16;
result := to_char_hex_digit(remaind) || result;
no := quot;
end loop;
return result;
end;
/
Then:
v734> select to_char_hex(rownum) from dba_users;
TO_CHAR_HEX(ROWNUM)
20 rows selected.
--
Have a nice day
Michel
Thomas Beetz <t.beetz_at_fnt.de> a écrit dans le message :
384B612D.46FBFBFD_at_fnt.de...
> Hello
>
> A simple problem:
> if i use
> select rownum from foo;
> i get
> rownum
> --------
> 1
> 2
> 3
> .
> .
> 10
> 11
> .
> .
>
> but i want
>
> rownum
> -------
> 1
> 2
> 3
> .
> .
> .
> A
> B
> .
> is there an easy way or must i write a simple function for this.
>
> Thanks thomas
>
Received on Mon Dec 06 1999 - 04:53:27 CST
![]() |
![]() |