Subject | merge tables |
---|---|
Author | Ivan Setya Darmawan |
Post date | 2006-05-01T11:42:21Z |
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
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