How to use Change Data Capture in Oracle (Step 2/4) Learn how to implement a Change Data Capture (CDC) in Oracle

In this tutorial, you will learn how to design a Job to generate the data representing the customers (ID, Name, Forename, Age) and to simultaneous load the data into the DATA and DWH databases to simulate the data synchronization.

This tutorial is part of a serie of four tutorials:
- [How to use Change Data Capture in Oracle (Step 1/4)]
- [How to use Change Data Capture in Oracle (Step 2/4)]
- [How to use Change Data Capture in Oracle (Step 3/4)]
- [How to use Change Data Capture in Oracle (Step 4/4)]

Download it!

Do you want to practice?

Download tutorialProject.zip includes all the jobs needed to carry out this tutorial. Please, download it!

You can also:
Send it!

Share it!
Next Step: [How to use Change Data Capture in Oracle (Step 3/4)]

 


Step 1: Create the Job


Create a job that allows you to create the Customers table in the two databases DWH and DATA, by placing components as in the screenshot:


Drag the connexion to the databases metadata DATA and DWH in the Job Designer to create  the output components.

The tReplicate component allows you to multiply the input flow as many times as required.

The Customers tables in the DWH and DATA databases must be identical at this stage.

Next

Configure your tRowGenerator as in the screenshot:

Do not forget to specify the id field as a primary key; this is necessary to work with CDC. To do so, check the id Key box.

The sequence method parameters are start value:
start value 1
step 1

In this exercise you need only to generate 10 rows.

Next

Configure the tOracleOutput components as the screenshot, modifying the connection data for your environment (Username = DATA, Table = customers, Action on table = Drop table if exists and create...).

Click Sync Columns button to retrieve the tRowGenerator schema.

Next

Configure the tOracleOutput components as the screenshot, modifying the connection data for your environment (Username = DWH, Table = customers, Action on table = Drop table if exists and create...).

Click Sync Columns button to retrieve the tRowGenerator schema.

Next

Press F6 to run the Job. 

Next

In the Repository, click Metadata > Db Connections > CDC_Oracle > DATAOracle. Right click DATAOracle and select Retrieve Schema.

Next

In the table, select Customers and click Next.

Next

Select CUSTOMERS and click Finish.

Next

Repeat these actions for the DWHOracle.

In the Repository, click Metadata > Db Connections > CDC_Oracle > OracleDWH. Right click OracleDWH et select Retrieve Schema.

Next

Select CUSTOMERS and click on Next.

Next

Select CUSTOMERS and click on Finish.

Next

Step 2: Implement the CDC for the Customers table


We will now implement the CDC, creating a subscriber.

Click Metadata > Db Connections > CDC_Oracle > DATAOracle. Right-click CDC Foundation and select Create CDC.

In the Set Link Connection field, select DB (ORACLE_SID): CDCOracle, it allows you to create a link between the tables in the DATA database and those in the CDC database.

Next

Click Create Subscriber and then click Execute and Finish.

Next

The TSUBSCRIBERS table is now created in the CDC database.

A link is created to this table in DATAOracle > CDC Foundation > CDCOracle > TSUBSCRIBERS.

Next

Step 3: Create Subscriber


Click Metadata > DB Connections > CDC_Oracle > DATAOracle > Table schemas > CUSTOMERS and select Create CDC.

In the new window, check the Insert, Update and Delete boxes and name the subscriber dwh-customers.

Click Execute. This allows you to add a row to the TSUBSCRIBERS table of the CDC database containing the name of the subscriber, the table to be monitored and the creation date.


Next

To verify the content of the table use Talend or Oracle.

Next
The tcdc_customers table has been created in the Oracle database. It contains four columns, plus the column which represent the primary key.

- TALEND_CDC_SUSCRIBERS_NAME represents the DWH_Customers subscriber that you just created.
- TALEND_CDC_STATE is set to "0" if the modification has been consumed by the subscriber, and "1" if not.
- TALEND_CDC_TYPE represents the type of modification that has been carried out: "I" for Insert, "U" for Update, "D" for Delete.
- TALEND_CDC_CREATION_DATE represents the date of the modification.
- ID represents the data which has been modified, and is identified by its primary key.

Next
The schema of the tcdc_view_customers view contains the columns:

TALEND_CDC_TYPE, TALEND_CDC_SUSCRIBERS_NAME, TALEND_CDC_CREATION_DATE, ID, NAME, FIRSTNAME and AGE.

The first three columns have the same role as before. The four others represent the Customers table. It allows you to take a snapshot of the modifications at a given moment.

 

    Download it!     Send it!     Share it!

Do you want to practice?

Download tutorialProject.zip includes all the jobs needed to carry out this tutorial. Please, download it!

Friends / colleagues may be interested in this tutorial? Send it to them!

You liked this tutorial ? Support it!

[ top ]