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;

 

Tags:

Oracle

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Search

Calendar

«  April 2014  »
SuMoTuWeThFrSa
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent comments

Archive