Subject | Re: Deleting a duplicate row from a corrupt database |
---|---|
Author | Alexander V.Nevsky |
Post date | 2004-05-13T11:00:57Z |
--- In firebird-support@yahoogroups.com, Ales Smodis <aless@z...> > So
I'm left with two rows with the same key and don't know how to delete
multy-segment PK modifying Where, and for deleting many duplicate by
removing Exit and skipping first row, selected column have no meaning:
CREATE PROCEDURE DELETE_ONE_DUPLICATE(ID INTEGER)
DECLARE VARIABLE K INTEGER;
BEGIN
FOR SELECT ID FROM DAMAGED_TABLE
WHERE ID=:ID
INTO :K
AS CURSOR TMPCURSOR
DO
BEGIN
DELETE FROM DAMAGED_TABLE
WHERE CURRENT OF TMPCURSOR;
EXIT;
END
END
Theorethically the same can be done selecting RDB$DB_KEY on client
side and using it in delete, but personally I have not much experience
with this, if you are interested in general sense, you can try.
Best regards,
Alexander
I'm left with two rows with the same key and don't know how to delete
> one of them since the delete statement doesn't take a plan and whateverAles, I usually make it following next idea, which you can adopt to
> condition I use to identify the row I want to delete, it always uses an
> index.
multy-segment PK modifying Where, and for deleting many duplicate by
removing Exit and skipping first row, selected column have no meaning:
CREATE PROCEDURE DELETE_ONE_DUPLICATE(ID INTEGER)
DECLARE VARIABLE K INTEGER;
BEGIN
FOR SELECT ID FROM DAMAGED_TABLE
WHERE ID=:ID
INTO :K
AS CURSOR TMPCURSOR
DO
BEGIN
DELETE FROM DAMAGED_TABLE
WHERE CURRENT OF TMPCURSOR;
EXIT;
END
END
Theorethically the same can be done selecting RDB$DB_KEY on client
side and using it in delete, but personally I have not much experience
with this, if you are interested in general sense, you can try.
Best regards,
Alexander