Subject Re: [firebird-support] Tutorial create replicator FB 2.5
Author Milan Babuskov
allies_xposs@... wrote:
> I want to create simple program replicator

Replication is anything but simple.

However, if you really want to, here's an outline of how you could do
one-way replication:

- Create AFTER insert/update/delete triggers on all interesting tables.
- Make those triggers record the changes to some LOG table and fire some
event.
- Create a replicator application that listens to events, reads the LOG
table sequentially and applies changes to destination database
- To safeguard from triggers firing, the replication app. can use a
special username or role and have replication triggers fire only when
this user/role is not performing the change (via CURRENT_USER or
CURRENT_ROLE)

Of course, there are many issues to take care of:

- Format of LOG table(s). There are different strategies how to store
changed/deleted values. You can have multiple tables to accomodate
different datatypes efficiently. I prefer solution with 3 tables (one
for numbers, dates and small varchars, second for largest possible
varchar, and third for BLOBs).

- Conflict resolution. What to do when changes to destination database
fails.

- Generators/sequences. This would require to know application-specific
rules and possible modification of existing application
code/triggers/procedures because generators are outside transaction control.

Well, those are general issues you might encounter. I recommend that you
estimate whether it would cost you less to implement some existing
replication solution than build your own. For a list of existing
replicators, take a look here:

http://www.firebirdfaq.org/faq249

--
Milan Babuskov

==================================
The easiest way to import XML, CSV
and textual files into Firebird:
http://www.guacosoft.com/xmlwizard
==================================