Programming => Databases => Topic started by: pcurtis on January 19, 2021, 08:59:16 pm
Title: Database change
Post by: pcurtis on January 19, 2021, 08:59:16 pm
Hi All,
whats the best / correct way to be informed of changes to a DB / dataset?
I use Zeos and Sqlite
Thanks in advance.
Title: Re: Database change
Post by: Zvoni on January 20, 2021, 08:04:39 am
sqlite itself has a notification callback https://sqlite.org/c3ref/update_hook.html
Title: Re: Database change
Post by: madref on January 20, 2021, 09:03:50 am
When ever I use a form that has data from my database I use a query to get the specific data I need from that database. When that query has changed I update it.
Title: Re: Database change
Post by: cdbc on January 20, 2021, 10:09:05 am
Hi Implement the Observer pattern... It is built in, in the LCL (TObserved) in TPersistent You only need to build an Observer, with one method If need be, "steal" the implementation of TObserved in TPersistent and put it in your db-code ;) Two small classes with enormous effect. HTH Regards Benny
Title: Re: Database change
Post by: pcurtis on January 20, 2021, 11:33:55 am
@zvoni - any idea how to implement this in laz / fpc?
Title: Re: Database change
Post by: Zvoni on January 20, 2021, 01:31:26 pm
@zvoni - any idea how to implement this in laz / fpc?
Probably as a class-helper for sqlite3conn (never worked with Zeos). You should check first if the external function is already declared available in sqlite3conn (at least that's the place i would look in) The link describes the prototype of the Function which acts as a "Event"-Handler. From there......