Presentation is loading. Please wait.

Presentation is loading. Please wait.

By César Urdaneta.  Purpose ◦ Replicate records from different tables (for inserting / updating record), from a source database to a target one, keeping.

Similar presentations


Presentation on theme: "By César Urdaneta.  Purpose ◦ Replicate records from different tables (for inserting / updating record), from a source database to a target one, keeping."— Presentation transcript:

1 By César Urdaneta

2  Purpose ◦ Replicate records from different tables (for inserting / updating record), from a source database to a target one, keeping updated data from different catalogs.  Specific Objectives ◦ Send records, as they are inserted or updated from the database master toward slaves different databases in order to maintain data of those catalog up to date. ◦ Avoid human errors and rework, as result of loading information in all databases. ◦ Controlling the syncs of distinct tables, logging incidents in case of failure in data replication process.

3 BD Slave 1 After Insert Event After Update Event BD Slave 2 After Insert Event After Update Event BD Slave N After Insert Event After Update Event BD - Master The several tables has 2 triggers. Those triggers are AFTER INSERT for record inserted and AFTER UPDATE for record updated. Both triggers invoke Stored Procedures; whose they have the logic, validation rules for inserting / updating record and save within a log-table in case the failure on validation and other errors. The log is structured with 2 tables, whose purposed are storing general info of the error (timestamp, user, host, description) and detail (key-field, value). The project has a configuration table to indicate slaves DB to be used during the replication process. There are CRUD Stored Procedure that validate DB-Name entry with sysobjects table.

4  LOG_REPLICACION_FALLIDA (REPLICATION_FAILURE_LOG) is the header table that contains basic information of the error.  LOG_CAMPOS_FALLIDOS (FIELDS_FAILURE_LOG) is the details table that contains the name of the Unique / PK Indexed Fields and their respective value.

5 Assuming that there is a database called 'REPLICA_1', as shown in the drawing on the left, write the name of the SP, as shown in the SQL Server Management Studio and press F5, being as shown in the screen below.

6  There’s a Stored Procedure that generate triggers script given a table name.  The Stored Procedure validates the existence of the table given as parameter.  In the result panel, we select the trigger; copy into the clipboard, open a new query windows and paste the result.


Download ppt "By César Urdaneta.  Purpose ◦ Replicate records from different tables (for inserting / updating record), from a source database to a target one, keeping."

Similar presentations


Ads by Google