Subject Re: [firebird-support] Remove duplicate of table without constraints
Author Leonardo Carneiro
On Tue, Sep 13, 2011 at 11:32 PM, Leonardo Carneiro
<chesterman86@...>wrote:

> On Tue, Sep 13, 2011 at 5:53 PM, Ann Harrison <aharrison@...>wrote:
>
>> On Tue, Sep 13, 2011 at 3:45 PM, Leonardo Carneiro
>> <chesterman86@...>wrote:
>>
>> >
>> > How do i get the id of the tuple of a table? I mean the ID of the tuple
>> in
>> > a
>> > table, not the PK of the tuple. Have i jumped any doc that describe
>> this?
>> >
>> >
>> The id of a tuple in a table is not a relational concept. Tuples are
>> identified by column values. However, you can get the RDB$DB_KEY which is
>> sort of an id. However the RDB$DB_KEY is stable only for a single
>> transaction. Between transactions someone could delete one tuple with a
>> specific RDB$DB_KEY and another transaction could insert a new tuple that
>> could get the same RDB$DB_KEY value. Backing up and restoring a database
>> completely scrambles the RDB$DB_KEY values. Use a primary key.
>>
>>
>> Good luck,
>>
>> Ann
>>
>>
>> Hi Ann, very very thank you for your answer.
>
> I'm well aware that the good way is to use a primary key, but this case is
> very special.
>
> We have some big tables in the system that we are converting to a new
> format in runtime. The old data (from the the client table, for example) is
> being pumped to a temporary table with the new format (table client_tmp),
> and as the new data comes in, is being inserted in the two tables (client
> and client_tmp). For the sake of performance, we are not using any
> constraints on the temp table, since every select is being executed on the
> old table.
>
> Once all old data is pumped to the new table, the system drops the old
> table, creates a new one with the same name, but with the new format AND
> with constraints, and pump the data from the temp table to this new one.
>
> It looks like the software is allowing the insertion of duplicated data.
> While this will be fixed in the software side, i have to make a way to
> remove this duplicated tuples in this temporary table that has no PK.
>
> Again, tks for the tip.
>

Hi again. I used RDB$DB_KEY inside a execute block and worked like a charm.

Sorry for my poor english and tks again for the help.


-
Leonardo "Chester" Carneiro


[Non-text portions of this message have been removed]