Macromedia coldfusion 4.5-cfml language reference User Manual

Page of 608
314
CFML Language Reference 
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. You 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>