Woops, made a few blunders in there - but hey, you get the idea I'm sure ;)
Dom On 12/02/2008, Dominic Watson <[EMAIL PROTECTED]> wrote: > > Firstly, the column in the table absoutley *should* have a unique index or > constraint on it. Doing that will avoid any racing as the db will make it > impossible to insert dupes. With that in mind, your code could look > something like: > > <cfset recordInserted = false> > <cfset maxTries = 10> > <cfset counter = 0> > > <cfloop condition="not recordInserted and counter LT maxTries"> > <cfset recordInserted = true> > <cfset counter = counter + 1> > <cfset randomNumber = GetRandomNumber()> > <cftry> > <cfquery datasource="#ds#"> > SQL STATEMENT > </cfquery> > > <cfcatch> > <cfif errorIdUniqueConstraintError> <!--- I don't know how to check > that off-hand ---> > <cfset recordInserted = false> > <cfelse> > <cfthrow> > </cfif> > </cfcatch> > </cftry> > </cfloop> > -- Blog it up: http://fusion.dominicwatson.co.uk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;160198600;22374440;w Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:298781 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

