HiRDB Datareplicator Version 8 Description, User's Guide and Operator's Guide
You use C language to program an import information editing UOC routine. The target Datareplicator provides functions for use in creating your import information editing UOC routine. The following table lists the names of functions that can be used by an import information editing UOC routine and provides an overview of the functions.
Table 8-3 Overview of the functions provided for creating an import information editing UOC routine
| Function name | Function |
|---|---|
| hds_ubegin() (Editing start instruction) |
Issues an instruction to start editing of import information. The user is responsible for establishing connection with the target HiRDB or for initializing the environment. |
| hds_uedit() (Editing and processing instruction) |
Issues an instruction to edit, process, or execute synchronization point processing on the import information. The user is responsible for editing or processing the import information, issuing SQL statements, and outputting the information to a general file. |
| hds_uend() (Editing termination instruction) |
Issues an instruction to terminate the editing of input information. The user is responsible for disconnecting from the target HiRDB or for executing termination processing on the environment. |
#include<hds_ucommon.h> #include<hds_ureflect.h> int hds_ubegin(UINTERFACE_BLK *interface-block-name,long *status);
Table 8-4 Contents of the interface block (UINTERFACE_BLK)
| Member name | Length (bytes) | Attribute | Area name | Defined by | Description |
|---|---|---|---|---|---|
| auth_id | 8 | char | Authorization identifier | Caller | Connection authorization identifier specified in the import system definition |
| password | 30 | char | Password | Caller | Password specified in the import system definition |
| exsysid | 2 | char | Source Datareplicator identifier | Extractor | Source Datareplicator identifier specified in the source Datareplicator's extraction system definition, expressed as a string of lowercase hexadecimal characters. During data linkage with XDM/DS, 00 is set. |
| repid1 | 2 | char | Identifier 1 | Caller | Data linkage identifier specified in the import system definition |
| repid2 | 2 | char | Identifier 2 | Caller | Target Datareplicator identifier specified in the import system definition |
| *inherinf1 | 4 | char * | Inherited information 1 | Caller | Address of the area to be inherited to the hds_uedit() and hds_uend() functions |
| inherinf2 | 4 | long | Inherited information 2 | Caller | Information to be inherited to the hds_uedit() and hds_uend() functions |
| stopinf | 4 | long | Termination mode | Caller | UOC routine termination mode (this area is effective only during the hds_uend() function call): HDS_FLG_NORMAL Normal termination HDS_FLG_FORCE Forced termination |
Set the return value when control is returned to the caller. The following table shows the permissible return values.
Table 8-5 Return values from hds_ubegin()
| Code | Status | Mnemonic | Caller's action |
|---|---|---|---|
| 0 | Normal termination | HDS_RET_NORM | Resumes processing. |
| 4 | Minor error detected (resumable level) | HDS_RET_WARN | Outputs a message and resumes processing. |
| Other | Major error detected (unresumable level) | HDS_RET_ERR | Outputs a message, cancels processing, and terminates the process. |
If you have specified a transmission-suppressed original receiver identifier in the ndndidxxx operand (xxx: integer in the range 001 to 256) in the source Datareplicator's transmission environment definition, specify in the $PDCLTAPNAME HiRDB environment variable immediately before HiRDB's CONNECT processing a character string of up to 20 bytes beginning with hdssqle and ending with the source Datareplicator identifier.
The character string specified as the source Datareplicator identifier is the same as the one that is specified in the interface block (2-byte hexadecimal character string).
#include<hds_ucommon.h>
#include<hds_ureflect.h>
int hds_uedit(UINTERFACE_BLK *interface-block-name,
UREFLECT_BLK *import-control-block-name,
UDATA_BLK *key-information-block-name,
UDATA_BLK *import-data-block-name,
long *status);
Table 8-6 Contents of the import control block (UREFLECT_BLK)
| Member name | Length (bytes) | Attribute | Area name | Defined by | Description |
|---|---|---|---|---|---|
| updkind | 8 | char | Update type | Caller | Type of update processing on the source database (as an 8-byte character string, as shown below; if the type is shorter than 8 bytes, spaces are added):
|
| auth_id | 30 | char | Authorization identifier | Caller | Authorization identifier used to update the source database |
| tbl_id | 30 | char | Table identifier | Caller | Table identifier used to update the source database |
| upd_date | 4 | char | Update date | Caller | Date the source database was updated (date the update information was output to the journal). The date is displayed in unsigned packed decimal format (YYYYMMDD). |
| upd_time | 4 | char | Update time | Caller | Time the source database was updated (time the update information was output to the journal). The time is displayed in unsigned packed decimal format (HHMMSSTT, where TT is 1/100 sec.). |
| uapname | 8 | char | Source UAP name | Caller | Name of the user application program used to update the source database |
| extsysid | 4 | char | Source database's system ID | Caller |
|
| infflag1 | 1 | unsigned char | Reserved area1 | N/A | Reserved |
| infflag2 | 1 | unsigned char | Reserved area2 | N/A | Reserved |
| infflag3 | 1 | unsigned char | Reserved area3 | N/A | Reserved |
| reserve1 | 1 | char | Reserved area4 | N/A | Reserved |
| infflag4 | 4 | long | Reserved area5 | N/A | Reserved |
UDATA_BLK *key-information-block-name
Figure 8-4 UDATA_BLK and related structures
Table 8-7 Contents of UDATA_BLK
| Member name | Length (bytes) | Attribute | Area name | Defined by | Description |
|---|---|---|---|---|---|
| colnum | 4 | long | Number of columns | Caller | Number of columns for the mapping key or import data |
| *colinfptr | 4 | UCOLUMN_BLK * | UCOLUMN_BLK * address | Caller | Address of UCOLUMN_BLK |
Table 8-8 Contents of UCOLUMN_BLK
| Member name | Length (bytes) | Attribute | Area name | Defined by | Description |
|---|---|---|---|---|---|
| colname | 30 | char | Column name | Caller | Column name |
| coltype | 1 | unsigned char | Column data type | Caller | Column's data type. For details about the settings, see Table 8-10 Column data type mnemonics. |
| coloption | 1 | unsigned char | Column option | Caller | Column options, as shown below: HDS_COL_NOOPT (0x00): No options HDS_COL_NULL (0x01) Null data HDS_COL_MAPK (0x02): Mapping key: HDS_COL_MAPK is set only in the import data block. It is not set in the key information block. HDS_COL_ARRAY (0x04): Array column HDS_COL_REPET (0x08): Repetition column HDS_COL_ELMNL (0x10): Repetition column's element value is null. HDS_COL_REPTCOL (0x20): Specification of repetition structure
|
| elementnum | 4 | union | Repetition column's valid element number or number of abstract data types | Caller |
|
| mltcolkind | 1 | unsigned char | Repetition column update type | Caller | Update type for a repetition column, as shown below (this information is applicable only when the update type is UPDATE): HDS_COL_ADDV (0x01): ADD HDS_COL_DELV (0x02): DELETE HDS_COL_SETV (0x04): SET |
| adtfunc | 1 | char | Abstract data type import method | Caller | Always 0x01. |
| charset | 1 | char | Character set type | Caller | Character set type of the column data that is to be passed to the UOC routine
|
| reserve1 | 2 | char | Reserved area | N/A | Reserved |
| collen | 4 | long | Column data length | Caller | Column's data length. If the column option is null data, 0 is set. |
| dataptr | 4 | union | Data address | Caller | Address of the column data. If the column option is null data, the null pointer is set. For details about the settings, see Table 8-11 Data address mnemonics. |
Table 8-9 Contents of USUBSTR_BLK
| Member name | Length (bytes) | Attribute | Area name | Defined by | Description |
|---|---|---|---|---|---|
| reserve1 | 4 | int | Internal information 1 | Caller | Internal information |
| data_len | 4 | int | Internal information 2 | Caller | Internal information |
| reserve2 | 4 | int | Reserved area 1 | Caller | Reserved |
| substr_spos | 4 | unsigned int | SUBSTR start position | Caller | Start position of the data column to be obtained when the SUBSTR scalar function is used |
| reserve3 | 4 | int | Reserved area 2 | Caller | Reserved |
| substr_len | 4 | unsigned int | SUBSTR data length | Caller | Length of the data column to be obtained when the SUBSTR scalar function is used |
| reserve4 | 16 | char | Reserved area 3 | Caller | Reserved |
Table 8-10 Column data type mnemonics shows the column data type mnemonics, and Table 8-11 Data address mnemonics shows the data address mnemonics.
Table 8-10 Column data type mnemonics
| Column data type | Mnemonic | Data code |
|---|---|---|
| INTEGER | HDS_T_INT | (0xF1) |
| SMALLINT | HDS_T_SINT | (0xF5) |
| LARGE DECIMAL | HDS_T_DEC | (0xE5) |
| FLOAT | HDS_T_FLT | (0xE1) |
| DOUBLE PRECISION | HDS_T_DBL | (0xE1) |
| SMALL FLOAT | HDS_T_SFLT | (0xE3) |
| REAL | HDS_T_REAL | (0xE3) |
| CHARACTER | HDS_T_CHAR | (0xC5) |
| VARCHAR | HDS_T_VCHAR | (0xC1) |
| NCHAR | HDS_T_NCHAR | (0xB5) |
| NVARCHAR | HDS_T_NVCHAR | (0xB1) |
| MCHAR | HDS_T_MCHAR | (0xA5) |
| MVCHAR | HDS_T_MVCHAR | (0xA1) |
| DATE | HDS_T_DATE | (0x71) |
| TIME | HDS_T_TIME | (0x79) |
| TIMESTAMP | HDS_T_TIMESTAMP | (0x7D) |
| INTERVAL YEAR TO DAY | HDS_T_YTD | (0x65) |
| INTERVAL HOUR TO SECOND | HDS_T_HTS | (0x6F) |
| BLOB | HDS_T_BLOB | (0x93) |
| BINARY | HDS_T_BINARY | (0x91) |
| UNPACK | HDS_T_UNPACK | (0xFF) |
Table 8-11 Data address mnemonics
| Data type | Mnemonic | Address type |
|---|---|---|
| INTEGER | HDS_A_INT | long * |
| SMALLINT | HDS_A_SINT | short * |
| LARGE DECIMAL | HDS_A_DEC | char * |
| FLOAT | HDS_A_FLT | double * |
| DOUBLE PRECISION | HDS_A_DBL | double * |
| SMALL FLOAT | HDS_A_SFLT | float * |
| REAL | HDS_A_REAL | float * |
| CHARACTER | HDS_A_CHAR | char * |
| VARCHAR | HDS_A_VCHAR | char * |
| NCHAR | HDS_A_NCHAR | char* |
| NVARCHAR | HDS_A_NVCHAR | char * |
| MCHAR | HDS_A_MCHAR | char * |
| MVCHAR | HDS_A_MVCHAR | char * |
| DATE | HDS_A_DATE | char * |
| TIME | HDS_A_TIME | char * |
| INTERVAL YEAR TO DAY | HDS_A_YTD | char * |
| INTERVAL HOUR TO SECOND | HDS_A_HTS | char * |
| BLOB | HDS_A_BLOB | char * |
| UNPACK | HDS_A_UNPACK | char * |
| TIMESTAMP | HDS_A_TIMESTAMP | char * |
| BINARY | HDS_A_BINARY | char * |
| SUBSTR operation backward deletion update log | HDS_A_SUBSTR | USUBSTR_BLK * |
Set the return value when control is returned to the caller. The following table shows the permissible return values.
Table 8-12 Return values from hds_uedit()
| Code | Status | Mnemonic | Caller's action |
|---|---|---|---|
| 0 | Normal termination | HDS_RET_NORM | Resumes processing. |
| 4 | Minor error detected (resumable level) | HDS_RET_WARN | Outputs a message and resumes processing. |
| Other | Major error detected (unresumable level) | HDS_RET_ERR | Outputs a message, cancels processing, and terminates the process. |
#include<hds_ucommon.h>
#include<hds_ureflect.h>
int hds_uend(UINTERFACE_BLK *interface-block-name,
long *status);
Set the return value when control is returned to the caller. The following table shows the permissible return values.
Table 8-13 Return values from hds_uend()
| Code | Status | Mnemonic | Caller's action |
|---|---|---|---|
| 0 | Normal termination | HDS_RET_NORM | Resumes processing. |
| 4 | Minor error detected (resumable level) | HDS_RET_WARN | Outputs a message and terminates the process normally. |
| Other | Major error detected (unresumable level) | HDS_RET_ERR | Outputs a message and terminates the process normally. |
A target Datareplicator provides header files for the structures and mnemonics that are used as the interface for the hds_ubegin(), hds_uedit(), and hds_uend() functions.
The header files used with an import information editing UOC routine are stored in the following directory:
UNIX Datareplicator: /opt/hirdbds/include/
Windows Datareplicator: Datareplicator-installation-directory\include\
The following table lists and describes the header files for an import information editing UOC routine.
Table 8-14 Header files for an import information editing UOC routine
| Filename | Description | Members associated with the import information editing UOC |
|---|---|---|
| hds_ucommon.h | Structures and mnemonic codes common to import information editing UOC routines |
|
| hds_ureflect.h | Structures and mnemonics for an import information editing UOC routine |
|
You can manipulate only user-specific files (that are open) within the functions of an import information editing UOC routine. The following are the file-related rules:
To use the SQL descriptor area to update the target database, you must create the UOC routine by setting the necessary information from the UOC interface table into the SQL descriptor area. For the UOC routine to directly reference column data in the UOC interface table, it might be necessary to code in C language, depending on the data type. The following figure shows the relationships among the format of data indicated by the column data address in the UOC interface table, the length of real data, and the representation in C language.
Table 8-15 Relationships among the UOC routine's column data type, data length, and representation in C language
| UOC interface table | Size of data area (bytes) | Representation in C language | |
|---|---|---|---|
| Mnemonic | Length of column data | ||
| HDS_T_INT | 4 | 4 | long |
| HDS_T_SINT | 2 | 2 | short |
| HDS_T_DEC | Leading 2 bytes: precision Trailing 2 bytes: scaling |
Precision |
char data-area[real-data-length] |
| HDS_T_FLT | 8 | 8 | double |
| HDS_T_DBL | |||
| HDS_T_SFLT | 4 | 4 | float |
| HDS_T_REAL | |||
| HDS_T_CHAR | Length of character string (bytes) | UOC routine's column data length | char data-area[real-data-length] |
| HDS_T_MCHAR | |||
| HDS_T_VCHAR | Length of character string in the data section (bytes) | UOC routine's column data length + 2 | struct{ unsigned short real-data-length char data-area[real-data-length] } |
| HDS_T_NCHAR | Length of character string (characters) | UOC routine's column data length x 2 | char data-area[real-data-length] |
| HDS_T_NVCHAR | Length of character string in the data section (characters) | UOC routine's column data length x 2 + 2 | struct{ unsigned short real-data-length char data-area[real-data-length] } |
| HDS_T_DATE | 4 | 4 | char data-area[real-data-length] |
| HDS_T_TIME | 3 | 3 | char data-area[real-data-length] |
| HDS_T_YTD | Leading 2 bytes: precision (8) Trailing 2 bytes: scaling (0) |
5 | char data-area[real-data-length] |
| HDS_T_HTS | Leading 2 bytes: precision (6) Trailing 2 bytes: scaling (0) |
4 | char data-area[real-data-length] |
| HDS_T_BLOB (when the column option is not 0x80) |
Length of data in the data section (bytes) | UOC routine's column data length + 8 | struct{ long reserved-area unsigned long real-data-length char data-area[real-data-length] } |
| HDS_T_BLOB (when the column option is 0x80) |
32 | UOC routine's column data length + 8 | Table 8-9 Contents of USUBSTR_BLK |
| HDS_T_UNPACK | Length of UNPACK data (bytes) | Length of integer part + length of fraction part | char data-area[real-data-length] |
| HDS_T_TIMESTAMP | 7 + p: Number of decimal places |
UOC routine's data column data length | char data-area[real-data-length] |
| HDS_T_BINARY (when the column option is not 0x80) |
Length of data in the data section (bytes) | UOC routine's data column data length + 4 | struct{ long real-data-length char data-area[real-data-length] }# |
| HDS_T_BINARY (when the column option is 0x80) |
32 | UOC routine's column data length + 8 | Table 8-9 Contents of USUBSTR_BLK |
All rights reserved. Copyright (C) 2007, 2013, Hitachi, Ltd.