Example: Applying change data by using a CDC Transaction stage
This example demonstrates how to use IBM® InfoSphere® Change Data Capture (InfoSphere CDC) to read changes that occur on tables in an Oracle database and then use IBM InfoSphere DataStage® to replicate the changes to a target DB2® database.
When you use InfoSphere CDC to capture changes, the change data includes the before and after images of the data, along with control columns. The control columns provide additional details about the change data, such as when the change occurred and the type of operation that was performed. Depending on how replication is configured, the change data might be sent in a single record that includes the before and after images, or in multiple records.
Simply inserting the change data record into the target database might not meet your business needs. To remove the extra control columns and replicate only the change data, you can create a stored procedure and call it from the target connector stage.
Setting up source and target tables for the example
For this example, you set up a source table in an Oracle database and a target table in a DB2 database. You also create a stored procedure that is called when the target DB2 connector stage runs.
Before you begin
The log retention policy for the source database must be set to retain logs.
Procedure
Setting up replication
You use the IBM InfoSphere Change Data Capture Management Console to add and configure a new subscription. Before you can perform these steps, the InfoSphere CDC software must be installed and configured.
Before you begin
Install and configure the InfoSphere CDC software.
Procedure
Generating a template for the job
After you create a subscription in the InfoSphere CDC Management Console, you generate a template for the InfoSphere DataStage job.
Procedure
- In the Subscriptions tab of the Configuration perspective, right-click the subscription, and click . This option is available only after the subscription is correctly set up.
- In the dialog box that is displayed, browse to select the file named ORACLECH.dsx, and click Save.
- Copy the .dsx file to a location that is accessible by the computer where InfoSphere DataStage and QualityStage Designer is installed.
Importing and configuring the job
When you generate the template job, some of the stage properties are set to values that are accurate for the subscription. However, you must update the job to specify settings that were not known when the job was generated.
Procedure
Starting the subscription and running the job
You start the subscription in the InfoSphere CDC Management Console. If auto-start is selected, starting the subscription automatically starts the InfoSphere DataStage job. If auto-start is not selected, you must start the job manually.
Procedure
- Log on to the InfoSphere CDC Management Console.
- Open the Monitoring perspective.
- In the Subscriptions tab, right-click the subscription named ORACLECH, and select Start Mirroring.
- Select Continuous to replicate continuously until the subscription is stopped.
- If the job is not configured to start automatically, start the job. In the Designer client, open the compiled job, and click Run. When the job is running, the links turn blue, and you can see that the row count for the bookmark link increments.
- In Monitoring perspective of the InfoSphere CDC Management Console, verify that the state of the subscription is Mirror Continuous.
Writing change data to the target database
When you update the source database tables, InfoSphere CDC sends the change data to the CDC Transaction stage, which sends the change data to the target DB2 connector stage. The target DB2 connector stage then calls the stored procedure to replicate the change data to the target.