Subject Re: Getting duplicate records in a table
Author Adam
--- In firebird-support@yahoogroups.com, Kjell Rilbe
<kjell.rilbe@...> wrote:
>
> Adam wrote:
>
> > It is a regular operation, potentially every couple of minutes. A
> > service is run that makes some changes to the table (a mini
> > replication if you like). Triggers then store a notification
record in
> > the table. If the application does not check its notifications
for a
> > while, there may be many notifications for the same record (which
has
> > changed many times in the interim).
> >
> > Of course a distinct is used in the query to retrieve the
records, but
> > I don't like the idea of letting it go, particularly if the
> > application is shut down for an extended period of time (someone
goes
> > on holidays for example).
>
> Do you actually need to delete all duplicates and insert a new one?
> Wouldn't it be sufficient to delete all of the duplicates except
one?

No, you always need to insert a notification record, or you can get
the scenario where the application reads its notifications at the
same time that you add a new notification, then the notification
would be cleared before the new record has been committed. You would
then end up with an updated record and no notification record to
trigger the synchronisation.

Adam