Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Does anyone know how to convert from decimal to hex???

Re: Does anyone know how to convert from decimal to hex???

From: Chrysalis <cellis_at_iol.ie>
Date: 1997/06/20
Message-ID: <33A9D854.1CE8@iol.ie>#1/1

Timothy C. Bracey wrote:
>
> I'm wokring on a project that requires me to have hex values. Currently they
> are stored as decimal. Does anyone know a way of converting from dec. to
> hex. without having to use or write some pro C code?
>
> (snip)

create or replace

   function DEC_TO_HEX

      (dec number) return varchar2 as
      n   number := dec;
      rm  number;
      hex varchar2 (16);
   begin
      loop
         for i in 0 .. 1
         loop
            rm  := mod(n,16);
            hex := concat(ch(rm),hex);
            n   := trunc(n/16);
         end loop;
         if n = 0 then exit; end if;
      end loop;
      return hex;

   end DEC_TO_HEX;

Hope this helps.

Chrysalis. Received on Fri Jun 20 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US