Please enable JavaScript to view this site.

A Simple Replication script requires DESCRIPTIONS for each Source and Target DATASTORE as well as either a straight mapping procedure for each table or use of the REPLICATE Command as shown in the sample script below. In the example Descriptions are in-line rather than through external files. In the sample script, a CDCzLog type Publisher uses TCP/IP to publish and transport data to the target Apply Engine. The Main Select section contains only references to the Source and Target Datastore aliases and the REPLICATE Command.  Individual mapping procedures are not required in this case.

The sample script, DB2TODB2, is listed below. Note how the same table descriptions are used for both Source and Target environments, how the Schema, which may have been present in the descriptions is overridden and how a single function, REPLICATE performs all the work. See the Engine Reference for more details regarding the use of the REPLICATE Command.

If you choose to exercise this script, which is based on IBM's Db2 IVP tables, it will be necessary to create two copies of the DEPT and EMP tables as referenced in the script on the target system. Once that is complete, the script can be parsed and exercised.  

-------------------------------------------------------------

--     DB2 REPLICATION SCRIPT FOR ENGINE: DB2TODB2          

-------------------------------------------------------------

--  SUBSTITUTION VARS USED IN THIS SCRIPT:                  

--   %(ENGINE) - ENGINE / REPORT NAME                      

--   %(HOST) - HOST OF Capture                              

--   %(PORT) - TCP/IP PORT of SQDAEMON                      

--   %(PUBN) - Capture/Publisher alias in sqdagents.cfg    

--   %(SSID) - DB2 Subsystem ID                            

-------------------------------------------------------------

-- CHANGE LOG:                                              

-- 2018/01/01: INITIAL RELEASE                              

-------------------------------------------------------------

JOBNAME %(ENGINE);                                          

RDBMS NATIVEDB2 %(SSID);                                    

OPTIONS CDCOP('I','U','D');                                  

                                                           

-------------------------------------------------------------

--         DATA DEFINITION SECTION

-------------------------------------------------------------

---------------------------                                  

-- Source Data Descriptions                                  

---------------------------                                  

BEGIN GROUP SOURCE_DDL;                                      

DESCRIPTION DB2SQL DD:DB2DDL(EMP)   AS S_EMP;              

DESCRIPTION DB2SQL DD:DB2DDL(DEPT)   AS S_DEPT;              

END GROUP;                                                  

                                                           

---------------------------                                  

-- Target Data Descriptions                                  

---------------------------                                  

--  None required for Straight Replication      

                                               

---------------------------                      

-- Source Datastore(s)                          

---------------------------                      

DATASTORE cdc://%(HOST):%(PORT)/%(PUBN)/%(ENGINE)

        OF UTSCDC                              

        AS CDCIN                              

         RECONNECT                              

        DESCRIBED BY GROUP SOURCE_DDL          

;                                                

---------------------------                      

-- Target Datastore(s)                          

---------------------------                      

DATASTORE RDBMS                                  

        OF RELATIONAL                          

        AS TARGET                              

        FORCE QUALIFIER TGT                    

        DESCRIBED BY GROUP SOURCE_DDL          

        FOR CHANGE                            

;                                                

---------------------------                      

-- Variables                                    

---------------------------                      

--  None required for Straight Replication      

                                               

---------------------------                      

-- Procedure Section                            

---------------------------                      

--  None required for Straight Replication      

                                               

-------------------------------------------------

--  Main Section - Script Execution Entry Point  

-------------------------------------------------

PROCESS INTO TARGET                              

SELECT                                          

{                                              

-- OUTMSG(0,STRING(' TABLE=',CDC_TBNAME(CDCIN)  

--               ,' CHGOP=',CDCOP(CDCIN)        

--               ,' TIME=' ,CDCTSTMP(CDCIN)))  

                                               

--  Source and Target Datastores must have the same table names

  REPLICATE(TARGET)                            

}                                              

FROM CDCIN;