Subject | Re: Row ID |
---|---|
Author | Adam |
Post date | 2007-03-12T22:28:13Z |
--- In firebird-support@yahoogroups.com, "bkirk_lrs" <bkirk_lrs@...>
wrote:
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").
Is that *really* true? Don't you mean rather that you need to make
sure the legacy programs can issue the same select, insert, update and
delete statements it used to?
By using a trivial trigger and generators, you can automatically fill
a PK field if it is left empty in an insert.
You could also change the real table into an updatable view that looks
exactly like the original table for legacy, although that is probably
not required.
rows by a rowid (aka - oid, uid, row id, etc.).
In a relational database, there is no concept of a row number. Any row
number you find is simply an implementation artifact of the particular
database, and particularly should not be relied upon to be a static
value as if it is going to survive a backup-restore process. There are
some cases where you want to or need to get the internal row number
used by the particular dbms, but these are mainly to track down and
fix consistency issues rather than part of the design of normal
operation. If you need a way to identify a particular record, that is
what a primary key is for.
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? Otherwise it seems I may need to
keep all the data I post and search it every time I post something else!
I think you will find it is simpler than that.
Adam
wrote:
>post a question that I could not find the answer to. Here is the
> After lots of looking (perhaps in the wrong the places) I have to
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").
Is that *really* true? Don't you mean rather that you need to make
sure the legacy programs can issue the same select, insert, update and
delete statements it used to?
By using a trivial trigger and generators, you can automatically fill
a PK field if it is left empty in an insert.
You could also change the real table into an updatable view that looks
exactly like the original table for legacy, although that is probably
not required.
> Since my limited database background does not includeInterbase/Firebird, I have not been able to figure out how to pull
rows by a rowid (aka - oid, uid, row id, etc.).
In a relational database, there is no concept of a row number. Any row
number you find is simply an implementation artifact of the particular
database, and particularly should not be relied upon to be a static
value as if it is going to survive a backup-restore process. There are
some cases where you want to or need to get the internal row number
used by the particular dbms, but these are mainly to track down and
fix consistency issues rather than part of the design of normal
operation. If you need a way to identify a particular record, that is
what a primary key is for.
> There are only 5 items in the table schema (1 date stamp and 4ints) 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? Otherwise it seems I may need to
keep all the data I post and search it every time I post something else!
I think you will find it is simpler than that.
Adam