Subject Re: [firebird-support] Is there a way to check if the table was modified?
Author Ann Harrison
On Fri, May 24, 2013 at 9:20 AM, un_spoken <brucedickinson@...> wrote:

> .
>
> If I perform an update/ insert/ delete query on a given table does
> Firebird is storing somewhere the time of last change on this table?


No.

> Or something like counter of changes?

No.

> Can I pull this info out by writing a query?
>
No. (I guess that was obvious.)

>
> This would be very usefull for me because I need to pull out data from a
> table when it has been changed. Before pulling out the data I could check
> this marker and compare it with previous marker. If there was not any
> change I wouldn't have to pull out the data at all.
>

Create a table that consists of just a LastChanged column. Put a
multi-function trigger on the target table that stores the CurrentTimestamp
in the new table whenever a change is made to the target table. Put a
descending index on LastChanged to optimize retrieving MAX (LastChanged).
Putting the LastChanged column in the target table works for insert and
update, but there's no point in storing important information in a record
that you just deleted.

If I were doing it, I'd add a RecordNumber column to the new table to store
the RDB$DB_KEY of the changed record and a operation so I could tell what
happened to the record (Insert/Update/Delete). That way you don't have to
look at the whole table to see what changed.

Good luck,

Ann

>
>
>


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