Or, you could make sure the directory field must be unique. Then, always do an SQL INSERT inside cftry/cfcatch blocks. If the directory doesn't exist, it will be added to the table. If it does exist, the cfcatch blocks just don't do anything.
Sure, it may cause some erros in the database logs, but it will reduce the number of data base interactions by two. Six of one, 1/2-dozen of the other... -----Original Message----- From: Andrew Scott [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 01, 2004 7:49 PM To: CF-Talk Subject: RE: CFDIRECTORY question There are a number of ways to do this, but the easiest and not sure if it is the quickest way. Is to loop through and do a query to see if that directory is listed in the database if it isn't then do an insert into the database. Regards, Andrew Scott -----Original Message----- From: Robert Orlini [mailto:[EMAIL PROTECTED] Sent: Thursday, 2 December 2004 7:42 AM To: CF-Talk Subject: CFDIRECTORY question I have this cfdirectory code (see below) that I want to read a list of directory names and then insert into a table. However, this script will be running each time a user accesses drop-down list. I want to list the current directories and any new directory names that have been added. At this point it will add the directory names numerous times along with any new directories. How can it just add new directories to the table using this cfdirectory script? Thanks! <cfdirectory directory="#GetDirectoryFromPath(GetTemplatePath())#" name="myDirectory"> <cfloop query="myDirectory"> <cfif type EQ "dir"> <CFQUERY name="get" datasource="marketing"> INSERT INTO directories (name) VALUES ('#mydirectory.name#') Where #mydirectory.name# != '#name#' </CFQUERY> </cfif> </cfloop> Robert O. HWW ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Silver Sponsor - RUWebby http://www.ruwebby.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185893 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

