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

Home -> Community -> Usenet -> c.d.o.server -> Re: GUID to CHAR conversion function?

Re: GUID to CHAR conversion function?

From: Vladimir M. Zakharychev <bob--nospam--_at_dynamicpsp.com>
Date: Wed, 22 Mar 2006 12:07:57 +0300
Message-ID: <dvr45j$16dt$1@hypnos.nordnet.ru>


Troy,

Built-in HEXTORAW function will handle the char to raw conversion:

HEXTORAW(TRANSLATE(your_guid_string,'0{-}','0'))

TRANSLATE is there to remove those curly braces and dashes from the input string before converting it to raw. For converting a raw guid back to formatted string you will probably need to create your own formatting function that will insert dashes in proper positions. To get a converted string without dashes you use RAWTOHEX built-in function on raw guid value. You can then insert dashes into it like this:

return substr(guid,1,8)||'-'||substr(guid,9,4)||'-'||substr(guid,13,4)......

Hth,

   Vladimir M. Zakharychev
   N-Networks, makers of Dynamic PSP(tm)

<Troy.Rudolph_at_ca.com> wrote in message
news:1142628614.440513.116480_at_j52g2000cwj.googlegroups.com...
> Hi All,
>
> I am an Oracle newbie and could use a little help, please. We are
> porting an app to Oracle that already runs with Ingres and MSSQL. Our
> UUID (GUID) columns are stored as RAW(16). I would like to write a
> function that will convert the 36-char (or 38-char) GUID string to
> RAW(16) and a function to convert the RAW(16) to the 36-char string.
>
> When converting from CHAR to RAW(16), the input string would look like
> this: '00000000-0000-0000-0000-00000000000' or
> '{00000000-0000-0000-0000-00000000000} '.
>
> When converting from RAW(16) to CHAR, the output string would always
> look like '00000000-0000-0000-0000-00000000000'.
>
> Does anyone out there have such a function or can point me to one. I
> haven't found mention of anything like this in the Oracle doc.
>
> Thanks very much
> Troy Rudolph
>
Received on Wed Mar 22 2006 - 03:07:57 CST

Original text of this message

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