You can even take this one step further, for instance, one time I got stuck with a 
situation where a duplicate insert could be possible so I had to:

1) Use a cfcatch to detect a second record insert
2) Process whether this was a straight duplicate, or a modification from the original 
record

If Duplicate - Reject
If modified - Change the insert to an update

Only with CFCATCH was I ever able to pull something like this and keep the database 
queries and CF Logic down to an absolute minimum, CFTRY/CFCATCH has been one of the 
best things to hit cold fusion in a long time :-)

>>> [EMAIL PROTECTED] 07/21 1:35 PM >>>
If you're trying to capture duplicates of a single field value, you could
use the database to catch the error.  Set the field properties as Indexed
(no duplicates) in Access.  Then wrap your <cfquery> in a <cftry> block to
capture the error:

<cftry>
  <cfquery...>
    Insert ...
  </cfquery>
  <cfcatch type="database">
    ...There was an error in the insert statement...
  </cfcatch>
</cftry>

This will only stop exact matches (case-sensitive) and won't work if you
need to match multiple fields.

> -----Original Message-----
> From: Lisa Greenberg [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, July 21, 2000 10:50 AM
> To: cftalk
> Subject: Preventing duplicates prior to insert
>
>
> I would like to prevent duplicate entries from being
> inserted to a table (MS Access).  Is there a way to do this
> without querying the database and comparing the
> "pre-inserted data" with data currently in the table?
>
> Any leads in the right direction is most appreciated.
>
> -- Lisa
>
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/[email protected]/ 
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf 
> _talk or send a message to [EMAIL PROTECTED] with
> 'unsubscribe' in the body.
>

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/ 
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebarRsts&bodyRsts/cf_talk or send a message 
to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to