Search code examples
delphisynchronizationfirebirdfirebird-3.0

Copying remote Firebird table to local database


I have a remote Firebird 3.0 server with a database. In this database, there is a big table. The client very often queries this table during their work. There are too many clients and bad internet connection, so the work with this table is terrible. I made a local copy of this table via IBExpert into a temporary database, which is distributed with client application.

But now there is a need in a change of some values in this table (add new values and edit some olds). So I need some kind of synchronization - copying of remote modified table to client's local database.

The client application was made by use of Delphi Berlin 10.1. So the synchronization should be done by Delphi code.

Can you give me an idea, how it will be correctly to synchronize such a big table, please?


Solution

  • You could fire POST_EVENT on master database (for insert, update, delete (triggers)) to notify client applications that there are changes.

    Then your client would need to fire procedure (on local DB) to do a sync. This could be done by EXECUTE STATEMENT ON EXTERNAL

      FOR EXECUTE STATEMENT ('SELECT ... WHERE CURRENT_TIMESTAMP >= tablename.modifiedon')
      ON EXTERNAL 'SERVER/PORT:DBPATH'
    

    You should include date of insert/modified/delete in master DB.