You could also generate a hash of their name and address as the seed,
assuming there isn't 2 customers with the same name and address (and you
already have this data at this point)
On 27 Jan 2016 7:05 a.m., "Mike K" <afpwebwo...@gmail.com> wrote:

> Can you combine that random number with something sequential like maybe an
> index field?  that way you'll give the customer a random order number but
> still be able to keep uniqueness.      You could generate the random
> number,  then append the sequential index to it making a larger integer.
>
> Or you could use the UUID
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Adobe Certified Advanced ColdFusion Developer
> AFP Webworks
> http://afpwebworks.com
>
> On Wed, Jan 27, 2016 at 10:31 AM, Brian Knott <bkn...@jbk.com.au> wrote:
>
>> Hi everyone.
>>
>> I have an issue with inserting orders into a database.  What I currently
>> do is create a random number and insert that number into the database when
>> an order is inserted.  I then query the database to get the order number
>> (unique ID generated by SQL Server).  Using this order number I then insert
>> the items into an item table.
>>
>> The issue is that its possible for 2 orders to end up with the same
>> unique number, this is because the random function is not actually that
>> random.  If two people are submitting orders at the same time, they get the
>> same random number.  This means that all of the items ordered go to one
>> customer, and the other customer gets no items.
>>
>> Current code for the random number is
>>
>> <cfset session.order.uniquenumber = RandRange(1,99999999) + now()>
>>
>> Is there a more reliable way of doing this?
>>
>> Brian
>>
>>
>> --
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "cfaussie" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cfaussie+unsubscr...@googlegroups.com.
> To post to this group, send email to cfaussie@googlegroups.com.
> Visit this group at https://groups.google.com/group/cfaussie.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cfaussie+unsubscr...@googlegroups.com.
To post to this group, send email to cfaussie@googlegroups.com.
Visit this group at https://groups.google.com/group/cfaussie.
For more options, visit https://groups.google.com/d/optout.

Reply via email to