CreateUUID

Returns a Universally Unique Identifier (UUID) formatted as `XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXX' where `X' stands for a hexadecimal digit (0-9 or A-F).

Syntax

CreateUUID()

Usage

Each UUID returned by the CreateUUID function is a 35-character-string representation of a unique 128-bit integer. Use the CreateUUID function when you need a unique string that you will use as a persistent identifier in a distributed environment. To a very high degree of certainty, this function returns a unique value; no other invocation on the same or any other system should return the same value.

UUIDs are used by distributed computing frameworks, such as DCE/RPC, COM+, and CORBA. With ColdFusion, you can use UUIDs as primary table keys for applications where data is stored on a number of shared databases. In such cases, using numeric keys may cause primary key constraint violations during table merges. By using UUIDs, you can eliminate these violations because each UUID is unique.

Examples

<!--- This example shows how to use CreateUUID --->

<HTML>
<HEAD>
<TITLE>CreateUUID Example</TITLE>
</HEAD>

<BODY>
<H3>CreateUUID Example</H3>

<P>
This example uses CreateUUID to generate a UUID when
you submit the form. <CFFORMYou can submit the form as many times as you 
wish.
</P>

<!--- This code checks to see if the form was submitted, then creates a 
    UUID if it was. --->

<CFIF IsDefined("Form.CreateUUID") Is True>
    <HR>
    <P>Your new UUID is: <CFOUTPUT>#CreateUUID()#</CFOUTPUT></P>
</CFIF>

<FORM action="createuuid.cfm" METHOD="post">

<P><INPUT TYPE="Submit" NAME="CreateUUID"> </P>
</FORM>

</BODY>
</HTML>