Subject RE: [firebird-support] merge tables
Author Paul Mercea
Hi

I had same problem like you.
First question , for me, was : "Data should be unique or not?" If south and
nord station have right to input new customer is posible for one customer to
create 2 distinct records. To avoid this i have meade a central database for
inserting unique records (customers, products, barcodes,etc) and that
database is sincronized with others.
Other questions was: "Replication is bidirectional?" For that i use one
field for each table who's gonna replicate to identify location.


Regards,
Paul M

-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Ivan Setya Darmawan
Sent: Monday, May 01, 2006 2:42 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] merge tables

Hi,

Assume I have 2 branch offices. One at Northpole and the other at
Southpole (brrbb). Each of them has a same customer table with fields
like this:

customers
----------------------
cust_id VARCHAR(20)(PK)
cust_name VARCHAR(80)

And now has come consolidation day. I need to merge northpole customer
table and southpole customer table to a single customer table in
headquater database.

I think, using autoincrement for cust_id is not a choice, coz it could
arise PK constraint error or cust_id replaced with new increment
value. So, I decide using before insert trigger for cust_id for each
table (including customers table at headquarter) like this:

BEGIN
/* Trigger body */
IF (NEW.CUST_ID IS NULL) THEN
NEW.CUST_ID = RAND();
END

and I hope merging those table become visible.

Do I on right track here or anyone has many better ideas?

TIA
#Ivan Darmawan





++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !

Also search the knowledgebases at http://www.ibphoenix.com

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Yahoo! Groups Links