> From: Hardy Merrill [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 28, 2001 2:06 PM
> To: [EMAIL PROTECTED]
> Subject: db independent way of detecting duplicates?

> I'm wondering what other people have developed as database
> independent way(s) of determining if the insert or update being
> done results in a duplicate key situation.
> 
> I can think of 2 methods to handle this:
>   1. before doing the insert or update, for *EACH AND EVERY*
>      unique key defined for a table, do a select with the where
>      clause looking for equality on all the fields in the unique
>      key - if any of those selects find rows, then your insert
>      or update would cause a duplicate.

This method is just asking for a race condition, and you'll end
up with one process attempting a duplicate insert anyway, so I'd just
go with the second method...

-Douglas Wilson

Reply via email to