User-defined function to convert from RAW(16) to a GUID in Oracle

by timvasil 1/20/2009 11:32:00 AM

CREATE OR REPLACE
FUNCTION RAWTOGUID
( RawData IN RAW
) RETURN VARCHAR AS

BEGIN

declare HexData varchar(32) := rawtohex(RawData);

begin
return
    substr(HexData, 7, 2)
    || substr(HexData, 5, 2)
    || substr(HexData, 3, 2)
    || substr(HexData, 1, 2)
    || '-'
    || substr(HexData, 11, 2)
    || substr(HexData, 9, 2)
    || '-'
    || substr(HexData, 15, 2)
    || substr(HexData, 13, 2)
    || '-'
    || substr(HexData, 17, 4)
    || '-'
    || substr(HexData, 21, 12);
end;

END RAWTOGUID;

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Oracle

Related posts

Comments are closed

 

About the author

Tim Vasil Tim Vasil
I'm a software engineer living in Cambridge, MA.

E-mail me Send mail

Search

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent comments