HiRDB Datareplicator Version 8 Description, User's Guide and Operator's Guide

[Contents][Glossary][Index][Back][Next]

8.1.7 Sample import information editing UOC routine

This section explains the sample UOC routine that is stored in the target Datareplicator.

Organization of this subsection
(1) Storage directory and filename
(2) Extraction environment
(3) Import environment
(4) Details about processing

(1) Storage directory and filename

When you install the target Datareplicator, the sample file is stored in the following directory:

Directory
UNIX Datareplicator: /opt/hirdbds/lib/sample/
Windows Datareplicator: Datareplicator-installation-directory\sample\

Filename
hds_redit.ec

(2) Extraction environment

(a) Table subject to extraction processing

The following figure shows the structure of the sample table that is subject to extraction processing.

Figure 8-7 Structure of the sample table subject to extraction processing

[Figure]

Note:
In this sample, only SQTY is subject to update processing.
(b) Details about extraction processing

This sample executes the following extraction processing:

(3) Import environment

(a) Contents of the table subject to import processing

The following figure shows the structure of the sample table that is subject to import processing. The name of the target table is STOCK.

Figure 8-8 Structure of the target table (STOCK)

[Figure]

(b) Import definition

The import definition is shown below. This import definition is based on the following conditions:

format STOCK
NAME PCODE    /* product code    */
NAME PNAME    /* product name    */
NAME COLOR    /* color           */
NAME PRICE    /* price           */
NAME SQTY     /* stock quantity  */
load PCODE,PNAME,PRICE,SQTY from STOCK by '/users/replicator/sampleuoc';

(4) Details about processing

The editing start instruction function (hds_ubegin) executes CONNECT processing on the target HiRDB. The editing and processing instruction function (hds_uedit) executes INSERT, UPDATE, DELETE, PURGE, and COMMIT, as appropriate to the update type.

If UPDATE or DELETE results in an error (SQLCODE 100) because there is no row subject to update processing in the target table, the UOC routine ignores the erroneous update information and continues import processing. If any other SQL execution error occurs, the UOC routine executes ROLLBACK processing using the editing termination instruction function (hds_uend). The editing termination instruction function (hds_uend) executes ROLLBACK as required, and then executes DISCONNECT.

(a) Editing start instruction function (hds_ubegin)

The editing start instruction function (hds_ubegin) sets the authorization identifier and password from its UINTERFACE_BLK parameters into the embedded variables and issues CONNECT to the target HiRDB using these embedded variables as parameters.

(b) Editing and processing instruction function (hds_uedit)

SQL execution processing

The editing and processing instruction function (hds_uedit) issues the SQL statement specified for the update type in its UREFLECT_BLK parameter to the target HiRDB.

INSERT
The function obtains the update data address of each column in the target table on the basis of the import data block (UDATA_BLK), which is the hds_uedit function's parameter, and then sets each data in the embedded variable. The function then executes INSERT using the embedded variable as the parameter.

UPDATE
The function obtains the update data address of PCODE, which is the mapping key column, on the basis of the key information block, which is the hds_uedit function's parameter, and then sets the update data in the embedded variable. Because only the SQTY column in the source table is subject to update processing, the import data block, which is the hds_uedit function's parameter, contains the update information for the SQTY column. The function sets the update data for this SQTY column in the embedded variable.
The function executes UPDATE using the embedded variable for the PCODE column as the search condition value and the embedded variable for the SQTY column as the update value.

DELETE
The function obtains the update data address of PCODE, which is the mapping key column, on the basis of the key information block, which is the hds_uedit function's parameter, and then sets the update data in the embedded variable. The function then executes DELETE using the embedded variable as the search condition.

PURGE
The function executes PURGE TABLE specifying STOCK as the name of the target table.

COMMIT
The function executes COMMIT WORK.

Function termination processing

This function determines the return code and status code on the basis of the SQLCODE SQL execution result. The following figure shows the return codes and status codes based on the SQLCODEs.

Table 8-23 Return codes and status codes based on the SQL codes

SQLCODE SQL status Return code Status code
0 Normal termination HDS_RET_NORM (normal termination) N/A
100 Error indicating that the specified row was not found in the target table during UPDATE or DELETE processing HDS_RET_WARN (minor error) SQLCODE
Other# Error resulting in cancellation of import processing HDS_RET_ERR (serious error) SQLCODE

#: The function sets -1 in inherited information 2 in the interface block (UINTERFACE_BLK), which is the hds_uedit function's parameter, as the flag for execution of ROLLBACK.

(c) Editing termination instruction function (hds_uend)

The editing termination instruction function (hds_uend) executes ROLLBACK and DISCONNECT. It executes ROLLBACK only when inherited information 2 is -1 in the interface block (UINTERFACE_BLK), which is the hds_uend function's parameter.