I'd let the database create the number.  But anyway,  you can do it like this:

<cfquery name="getnumbers" datasource="#variables.dsn#">
SELECT max(tableID) as Lastnumber from tablename
</cfquery>
<cfset newID = getNumbers.Lastnumber + 1 />

I have functions where i do this, but generally you'd be best to let
the databaes do it for you.

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month




On 12/21/07, Cutter (CFRelated) <[EMAIL PROTECTED]> wrote:
> Your db platform doesn't support autonumber?
>
> Steve "Cutter" Blades
> Adobe Certified Professional
> Advanced Macromedia ColdFusion MX 7 Developer
> _____________________________
> http://blog.cutterscrossing.com
>
> Rick Sanders wrote:
> > Hello list,
> >
> >
> >
> > I've done dynamic ID's before in .net and xml. I can't seem to figure out
> > how to do it in CF. Here's what I want to do:
> >
> >
> >
> > -          Query the database with the ID's.
> >
> > -          Sort the ID's in proper numerical order
> >
> > -          Grab the last ID (largest number which will be the last row of
> > the query)
> >
> > -          Then, add 1 to the number
> >
> >
> >
> > If someone has a better idea for a unique ID, I'm open to suggestions.
> >
> >
> >
> > Happy Holidays!
> >
> >
> >
> > Rick Sanders
> >
> > Webenergy
> >
> > Canada: 902-401-7689
> >
> > USA:       919-799-9076
> >
> > Canada: www.webenergy.ca
> >
> > USA:       www.webenergyusa.com
> >

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:295182
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to