Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to generate unique IDs?

Status
Not open for further replies.

NRK

Technical User
Feb 13, 2002
116
US
I am very new to ColdFusion and am trying to learn about its bounds. This is my first foray into database design for a web-based interface so I am unsure about the feasibility of this question.

I created an Access database that initially used Access as the front end. One of the functions that I created was the dynamic generation of record IDs. The complex aspect was that it had to reference one table (Category) and determine the next available ID and, then, append it to another table (Master Record).

I would need to do something similar with ColdFusion but am unsure of how to go about it.

Any and all advice would be greatly appreciated. Please let me know if you need any additional information.

Thanks!
 
<cftransaction>
<!--- get Category ID... --->
<cfquery name=&quot;qGetCategoryID&quot; datasource=&quot;dbn&quot; dbtype=&quot;ODBC&quot;>
SELECT MAX(Category_ID) AS newID FROM Category;
</cfquery>

<cfquery name=&quot;qNewRecord&quot; datasource=&quot;dbn&quot; dbtype=&quot;ODBC&quot;>
INSERT INTO [Master Record] ([Master Record ID]) VALUES (#qGetCategoryID.newID# + 1);
</cfquery>
</cftransaction>

I have enclosed everything into the cftransaction tags to ensure that no record is changed while new record is inserted; cftransaction has main purpose to provide mechanism to execute both queries or none Sylvano
dsylvano@hotmail.com
 
Fantastic - thanks so much for your help!

It makes much sense and I appreciate your quick response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top