Subject Re: [firebird-support] deleting duplicate records
Author David Zvekic
Dixon Epperson wrote:
> The table I am working with cannot have any restraints or key fields
> because there are times when a duplicate record may be desired. I
> know I could put an index number on each record and get rid of
> unwanted duplicates that way but is there a way to do something like
> this?
>
> DELETE FROM TABLE WHERE $RDB_RECNUMBER=(SELECT $RDB_RECNUMBER FROM
> TABLE WHERE IDNUM=:id AND STCKNUM=:stknum AND QTY=:qt)
>
> Dixon Epperson
>
>

If you have 2 rows which are identical, how can you tell the difference between
the unwanted duplicate row, and a "wanted" duplicate row.

By definition, they are both the same row.

What is it that you are trying to accomplish with having the same data in a table
multiple times?

(there are ways to accomplish virtually anything you could have accomplished with duplicate rows,
without actually having any duplicate rows.)

David Zvekic


PS: failing that you use use RDB$DB_KEY to differentiate the rows, but it would be better if you pretend I
didn't say that. RDB$DB_KEY is not guaranteed to be consistant accross transactions. And not guaranteed
to be portable to future implementations.