DBD: Data Replication System - Utilities
1: The Bulk Table Setup utility
The Bulk Table Setup utility greatly simplifies the chore of setting up multiple tables for Data Replication. It is especially useful for generating all the SQL "CREATE TABLE" statements required by the database administrator to create the tables in the external replicated database. The utility automatically generates the proper SQL statement syntax for the Oracle, MySQL and Microsoft SqlServer database types and exports it to a file on your local workstation.
You start the Bulk Table Setup utility as follows:
GUI: DB Distributor Optional Modules / Data Replication / Utilities / Bulk Table Setup Utility
CHUI: D/R menu, option U3.
Using the Bulk Table Setup utility
- Select files by clicking on the "Select Files" button.
Specify which of the following two options you will use:
a. Setup selected files for replication?
If this option is selected, enter the following additional data:
– Target Code
– Queue Code
– Sequence
b. Generate SQL for selected files?
If this option is selected, select one of the following database types:
– Oracle (Default)
– MySQL
– SqlServer
If at least one of the above options has been selected, the "Proceed" button is enabled for use. Click "Proceed" to continue. The selected files will be set up for replication, the proper SQL table creation syntax will be generated, and an output file will be created.
You will be asked to provide a directory in which to save the file. The file "drsql.txt" will be saved in the specified directory (it will be overwritten if it already exists).
The SQL "CREATE TABLE" statements generated by the Bulk Table Setup utility can sometimes be wrong in the case where a data column value is case sensitive. For example, the table “IL1_ImageLibrary” has an attribute “IMAGE_KEY” which is case sensitive, but the SQL code generated by Bulk Table Setup does not mark that column as case sensitive. You must manually modify the SQL code before using it to create the table in a database.
In general, for external databases (Oracle, SqlServer and MySQL, and other ODBC-based databases) the assumption is:
- Table names and column names are case insensitive. For example, the strings AR1_Cust and AR1_CUST are assumed to both refer to the AR1 table and are considered equivalent when they appear within SQL statements.
- The data values within columns are case sensitive. For example, "Vendor" is not the same as "VENDOR" when they appear within SQL WHERE clauses.
It is a design decision by DemandBridge to not have database-specific clauses where they can be avoided within the SQL CREATE TABLE statements generated by the Bulk SQL Generator. This is done to minimize the complexity of generating SQL statements for different databases types. It is a complex job to keep track of the different data type terminologies used by the various database vendors.
2: The Target Analysis utility
The Target Analysis utility (also known as Target Verification) reviews all DB Distributor tables in a specified Data Replication target one table at a time, comparing each Providex table to its corresponding remote database table counterpart. It highlights any differences in table structure or record count between the two areas.
You start the Target Analysis utility as follows:
GUI: DB Distributor Optional Modules / Data Replication / Utilities / Target Verification
CHUI: D/R menu, option U1
The utility can be used with database targets such as MySQL, Oracle and Microsoft SQLServer.
Click the magnifier to browse the list of Data Replication targets, then choose one:
After choosing the target, click Proceed to analyze all tables related to that target; data will be displayed in a list box (click “Clear” to erase current data in the list box so you can rerun again on a clear screen). If you wish to export the data to an Excel spreadsheet, just click the export icon in the lower left of the window (see the following screenshot):
The utility compares DB Distributor file information with the replicated table information and detects the following issues:
- Records present in the DB Distributor file but not in the replicated table data
- Records present in the replicated table data, but not in the DB Distributor file
For instance, in the above screenshot the AP4_Vend table shows 129 records in the DB Distributor file, but 132 records in the MySQL database file. Similarly, the table API_OpenInvoice shows 278 records in DB Distributor, but 279 records in MySQL.
The utility can help recover from Data Replication errors caused by, e.g., connectivity issues, which might result in the replicated table data getting out of synchronization with the DB Distributor file data.
A guaranteed method of bringing replicated database records back into sync with the DB Distributor file data is to do the following:
- Run the "Target Analysis” utility to find out-of-sync tables & note the table names
- Truncate the out-of-sync table
- Run the "Initialize Replication” utility (see Chapter 7, above) for the table
- Repeat Step 2 and Step 3 if more than one table is out-of-sync
Note: The Target Analysis utility can use an ODBC database connection, if available. The most recent versions of Providex/Pxplus do not require this.
3: The Queue Analyzer utility
The Queue Analyzer utility displays current statistics related to the Data Replication queue. Data is summarized in three separate tabs: the Queues tab displays a record count by Queue Codes, the Tables tab displays a record count by Table names, and the Times tab display a record count by timestamp.
In particular, the Times tab can show trends in queue size over time. It can alert you to a stalled queue, or to database conditions (e.g. failed database connection attempts) that may be slowing the replication process.
You can start the Queue Analyzer utility as follows:
GUI: DB Distributor Optional Modules / Data Replication / Utilities / Queue Analysis
CHUI: D/R menu, option U4
Click “Analyze” to start the review; click “Clear” to erase the current display and allow you to rerun Analyze again on a clear screen.
The popup indicates that the analysis is in process; the final screen will eventually display three tabs that summarize different aspects of the current status of the Data Replication queue.
The Queues tab shows a count of outstanding (currently unreplicated) records waiting in the Data Replication queue, grouped by each of several known Queue Codes. Remember that each Queue Code represents a number of tables grouped together. Remember also that Queue Codes are independent, and that each Queue Code is processed by a separate data replication process (so replication for one Queue Code can be stopped, while replication continues for other codes).
Note in the following example that Data Replication is currently running with five different Queue Codes, representing a mixture of connections to several databases, including MySQL, Oracle and Microsoft SqlServer (for instance, the example shows there are currently 14726 unreplicated records grouped with Queue Code “TMA”):
The Tables tab displays a list of known tables in the Data Replication queue with their associated Queue Codes and record counts, ordered by Table name. Note in the following example that table AR1500 is being replicated to two different databases, since it is assigned to two different Queue Codes “AR” and “DBE”, therefore two separate data replication processes are running.
Note: Two different tables AR1500 and FM1500 are grouped with Queue Code “DBE”, therefore a single data replication process will replicate both tables to the same database destination.
The Times tab displays the total number of unreplicated records in the Data Replication queue at discrete instants in time. Time codes shown in the queue are encoded as:
YYddMM hh.mm
(e.g., two-digit year, two-digit month, and two-digit date followed by a space, then a two-digit hour and two-digit minute).
In the following example, note that there are 959 records in the queue on November 19, 2013, at 2:50PM [131119 14.50], but only 11 records left in the queue forty minutes later at 3:30 PM. [131119 15.30], and only 1 record left in the queue 10 minutes later at 3:40PM [131119 15.40]. This shows a normal progression in queue size over time as a batch of incoming records from Providex is processed and replicated to the various database connections.
4: The Clear Rep Flags utility
There is an internal flag in the database that indicates whether a DB Distributor file should be replicated. The Clear Rep Flags utility is used to clear the flags on those files that have not yet been manually set up by running the Table Setup utility.
The utility should be used if Data Replication is enabled and running but there are records in the Data Replication Queue (the DR2 file) for DB Distributor files not yet enabled for replication. In addition, when you get a new release, the update process will now check to see if you are currently replicating a file and will reset the internal flag.
This will keep you from having to re-select files for Data Replication that you have previously selected.
You clear the replication flags by executing the utility as follows:
GUI: DB Distributor Optional Modules / Data Replication / Utilities / Clear Rep Flags in Data Dict.
CHUI: D/R menu, option U2