Creating ColdFusion UUID's in Oracle
Have you ever needed to create a ColdFusion compatible UUID (8-4-4-16) in another environment? Here's an Oracle function I created to do just that. If you wanted to support other types of UUID's, such as Microsoft's (8-4-4-4-12) format, you could easily modify the concat's.
Note: Updated entry: Rodel noticed I had put a wrong index in the 4th and 5th set of the UUID. Good catch Rodel. Rather than leave the function broken, I updated the entry.
CREATE OR REPLACE FUNCTION CREATE_CFUUID RETURN VARCHAR2
IS
tmpVar VARCHAR2 (32);
cfVar VARCHAR (35);
/**********************************************************
NAME: CREATE_CFUUID
PURPOSE: Creates ColdFusion UUID from Oracle SYS_UID
REVISIONS:
Ver Date Author Description
--------- ---------- --------------- ------------------------------------
1.0 9/28/2005 Christopher Wigginton
Object Name: CREATE_CFUUID
Sysdate: 9/28/2005
********************************************************/
BEGIN
tmpVar := RawToHex(SYS_GUID());
cfVar := SUBSTR(tmpVar,1,8) || '-' || SUBSTR(tmpVar,9,4) || '-' || SUBSTR(tmpVar,13,4) || '-' || SUBSTR(tmpVar,17);
RETURN cfVar;
END CREATE_CFUUID;

