命令行下:
dbmlsrv9 -c "dsn=center" -v+ -x tcpip -dl -o mlserver.mls -zu+
dbmlsync -c "dsn=remote1" -v -o dbmlsync1.out -e "sv=remote1"
dbmlsync -c "dsn=remote2" -v -o dbmlsync2.out -e "sv=remote1" |
对remote2:
UPDATE emp SET deptno = '0005' WHERE empno = 1
COMMIT |
再次同步remote2
dbmlsync -c "dsn=remote2" -v -o dbmlsync2.out -e "sv=remote1"
对remote1
UPDATE emp SET deptno = '0002' WHERE empno = 1
COMMIT |
同步remote1
dbmlsync -c "dsn=remote1" -v -o
dbmlsync1.out -e "sv=remote1" |
对center:
CREATE GLOBAL TEMPORARY TABLE emp_new(
empno INTEGER NOT NULL PRIMARY KEY,
empname VARCHAR(20),
gender BIT,
deptno CHAR(4),
last_modified TIMESTAMP);
CREATE GLOBAL TEMPORARY TABLE emp_old(
empno INTEGER NOT NULL PRIMARY KEY,
empname VARCHAR(20),
gender BIT,
deptno CHAR(4),
last_modified TIMESTAMP)
CALL ml_add_connection_script(
'remote1',
'end_upload',
'DROP TABLE emp_new;
DROP TABLE emp_old');
CALL ml_add_table_script(
'remote1',
'upload_fetch',
'SELECT empno, empname, gender, deptno,
last_modified FROM emp WHERE empno = ?'
)
CALL ml_add_table_script(
'remote1',
'emp',
'upload_old_row_insert',
'INSERT INTO emp_old VALUES(?,?,?,?)');
CALL ml_add_table_script(
'remote1',
'emp',
'upload_new_row_insert',
'INSERT INTO emp_new VALUES(?,?,?,?)');
CALL ml_add_table_script(
'remote1',
'emp',
'resolve_conflict',
'CALL ResolveConflictDemo()');
COMMIT;
ALTER OR REPLACE PROCEDURE ResolveConflictDemo()
BEGIN
UPDATE emp e
SET e.deptno = en.deptno
FROM emp_new en
WHERE e.empno = en.empno
AND en.deptno < e.deptno;
DELETE FROM emp_new;
DELETE FROM emp_old;
END; | |