Setting up Trigger-Based CDC

6 Product TitleBookTitle as a Variable See Chapter Working with Changed Data Capture of the Oracle Fusion Middleware Developers Guide for Oracle Data Integrator for details on how to set up journalizing and how to use captured changes.

14.6.2 Setting up Log-Based CDC

This method is set up with the JKM DB2400 Journal Simple and used by the LKM DB2400 Journal to SQL. It uses also an RPG program to retrieve the journal content. 14.6.2.1 How does it work? A iSeries transaction journal contains the entire history of the data changes for a given period. It is handled by the iSeries system for tables that are journaled. A journaled table is either a table from a collection, or a table for which a journal receiver and a journal have been created and journaling started. Reading the transaction journal is performed by the a journal retriever CDCRTVJRN RPG program provided with Oracle Data Integrator. This program loads on demand the tables of the Oracle Data Integrator CDC infrastructure J tables with the contents from the transaction journal. This program can be either scheduled on the iSeries system or called by the KMs through a stored procedure also called CDCRTVJRN. This stored procedure is automatically created by the JKM DB2400 Journal Simple and invoked by the LKM DB2400 Journal to SQL when data extraction is needed.

14.6.2.2 CDCRTVJRN Program Details

This program connects to the native iSeries journal for a given table, and captures changed data information into the Oracle Data Integrator Journal J. The program works as follows: 1. Journalized table attributes retrieval: a. Table attributes retrieval: PK columns, J table name, last journal reading date. b. Attributes enrichment short names, record size, etc. using the QSYS.QADBXREF system table. c. Location of the iSeries journal using the QADBRTVFD API. 2. PK columns information retrieval: a. PK columns attributes short name, data types etc. using the QSYS.QADBIFLD system table. b. Attributes enrichment real physical length using the QUSLFLD API. c. Data preprocessing RPG to SQL datatype conversion for the primary key columns. 3. Extraction the native journal information into the J table: Table 14–2 IBM DB2 for iSeries Journalizing Knowledge Modules KM Notes JKM DB2 400 Consistent Creates the journalizing infrastructure for consistent journalizing on IBM DB2 for iSeries tables using triggers. JKM DB2 400 Simple Creates the journalizing infrastructure for simple journalizing on IBM DB2 for iSeries tables using triggers. 7 a. Native journal reading using the QJoRetrieveJournalEntries API. b. Conversion of the raw data to native SQL data and capture into the J table. c. Update of the changes count. This program accepts the parameters listed in Table 14–3 .

14.6.2.3 Installing the CDC Components on iSeries

There are two major components installed on the iSeries system to enable native journal reading: ■ The CDCRTVJRN Program. This program is provided in an archive that should installed in the iSeries system. The installation process is described below. ■ The CDC Infrastructure. It includes the standard CDC objects J tables, views, ... and the CDCRTVJRN Stored Procedure created by the JKM and used by the LKM to read journals. This stored procedure executes the CDCRTVJRN program. Installing the CDCRTVJRN Program To install the CDCRTVJRN program:

1. Identify the location the program SAVF file. It is located in the ODI_

HOMEsetupmanualcdc-iseries directory, and is also available on the Oracle Data Integrator Companion CD.

2. Connect to the iSeries system.

3. Create the default work library if it does not exist yet. You can use, for example,

the following command to create an ODILIB library: CRTLIB LIBODILIB

4. Create in this library an empty save file that has the same name as the SAVF file

mandatory. For example: CRTSAVF FILEODILIBSAVPGM0110 Table 14–3 CDCRTVJRN Program Parameters Parameter RPG Type SQL Type Description SbsTName A138 Char138 Full name of the subscribers table in the following format: Lib.Table. Example: ODILIB.SNP_SUBSCRIBERS JrnTName A138 Char138 Full name of the table for which the extract is done from the journal. Example: FINANCE.MY_COMPANY_ORDERS JrnSubscriber A50 Char50 Name of the current subscriber. It must previously have been added to the list of subscribers. LogMessages A1 Char1 Flag activating logging in a spool file. Possible values are: Y enable logging, and N to disable logging. Note: The program must be set up in a library defined in the Topology as the default work library for this iSeries data server. In the examples below, this library is called ODILIB.