Nobody said the initial logic was good ;-)

That's a good point.  Why does the unique ID have to be random?  Why isn't
your DB automatically generating a new unique ID (sequence, identity, or
auto numbering depending on DB)?

Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
t. 250.920.8830
e. [EMAIL PROTECTED]

---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com
----- Original Message -----
From: "Ezine" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, March 20, 2003 10:18 AM
Subject: RE: Unique random number?


> Eventually though..    this will cause a page to loop many times..   and
run
> the Query many times increasing load time and processor time.
>
> -Zine
> -----Original Message-----
> From: Bryan Stevenson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 20, 2003 1:14 PM
> To: CF-Talk
> Subject: Re: Unique random number?
>
>
> I'm having trouble seeing why you need a loop for this?? Can you explain?
>
> From your description I would think you'd follow these steps (conditional
> statements and not loops):
>
> 1) set your random number (as you have)
> 2) run a query to see if that number is used in either table (simple
SELECT
> statement)
> 3) IF there is a recordcount to the above query then it's in use - do
> whatever you need to do to handle this.  IF NO recordcount then use it as
> your new job number to create the record(s) you need.
>
> HTH
>
> Cheers
>
> Bryan Stevenson B.Comm.
> VP & Director of E-Commerce Development
> Electric Edge Systems Group Inc.
> t. 250.920.8830
> e. [EMAIL PROTECTED]
>
> ---------------------------------------------------------
> Macromedia Associate Partner
> www.macromedia.com
> ---------------------------------------------------------
> Vancouver Island ColdFusion Users Group
> Founder & Director
> www.cfug-vancouverisland.com
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Thursday, March 20, 2003 9:55 AM
> Subject: Unique random number?
>
>
> > Need to set a job number to a unique number, based of creating a number
> > using the RandRange function, but then I need to take that number and
> > bounce it off two access tables (called openjobs & closejobs) to see if
> > that random number is already used, then loop back if it is to start
over,
> > but if it isn't, then use it to create a new record in openjobs table.
> >
> > What I don't know how to do is the loop structure if  the number already
> > exists on one of the two tables.
> >
> > Could someone direct me in how the code would look starting with this
> CFSET
> > statement?
> >
> > <CFSET job_number = RandRange(1, 100000)>
> >
> > ...and as always, thanks in advance!
> >
> >
> >
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to