Subject Re: [firebird-support] Row ID
Author Helen Borrie
At 05:32 AM 13/03/2007, you wrote:
>After lots of looking (perhaps in the wrong the places) I have
>to post a question that I could not find the answer to. Here is
>the background info and question: I have a legacy Firebird
>database that I need to post data from and I cannot manipulate the
>database in any way (i.e., I need to work the database "as is").
>Since my limited database background does not include
>Interbase/Firebird, I have not been able to figure out how to pull
>rows by a rowid (aka - oid, uid, row id, etc.). There are only 5
>items in the table schema (1 date stamp and 4 ints) and
>a constraint using an index (as the primary key) that uses
>the timestamp and lane number (app-specific int value) columns. I
>have read about generators, but that there was not one created for
>this table. Is there any way to use a rowid (or equivalent) to
>ensure I don't post the same data twice?

Ann pointed you to the rdb$db_key, but this won't be guaranteed to
survive past the boundaries of the transaction.

I'm curious to know what your thinking is about using some *other*
unique value to "ensure I don't post the same data twice". The PK is
(by nature) unique so WHERE LANE_NUMBER = ? AND THETIMESTAMP = ? is
enough to ensure that you find the unique value for an update or
delete, and to cause a PK violation if you try to post the same
combination twice.

Surrogate PK identifiers, such as a Row ID or a generated unique
number, or indeed the rdb$db_key, make it easier to find things for
positioned updates, but they don't make any difference to the quality
of "uniqueness" in the compound key. A key is either unique or it is not.

./heLen