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

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

8.2.4 Syntax for the function used with a column data editing UOC routine

You use C language to program a column data editing UOC routine. The target Datareplicator provides a function for use in creating your column data editing UOC routine. The following table shows the function that can be used for a column data editing UOC routine and provides an overview of the function.

Table 8-26 Overview of the function provided for creating a column data editing UOC routine

Function name Function
hds_ucoleditX() (Edit column data) Receives column data to be edited and stores the data obtained after editing. The user is responsible for editing the data, and then storing the data obtained after editing.
Organization of this subsection
(1) hds_ucoleditX (edit column data)
(2) Header files used with a column data editing UOC routine

(1) hds_ucoleditX (edit column data)

A column data editing UOC routine uses the hds_ucoleditX function (X: 1-8). You can create eight UOC functions per Datareplicator system.

(a) Function format
#include<hds_ucommon.h>
#include<hds_ureflect.h>
 int hds_ucoleditX(UCOLENV_BLK *column-data-editing-interface-environment-block,
    UCOLUMN_BLK *pre-edit-import-column-information,
    UCOLUMN_BLK *post-edit-import-column-information,
    long *status);
(b) Explanation of the parameters

The parameters are explained below. The function's structure is defined in the column data editing UOC routine's header files. Do not update an area whose structure is defined by the caller. For details about the header files, see Table 8-33 Header files for the column data editing UOC.

UCOLENV_BLK
This block stores environment information for the column data editing interface. The following table shows the contents of UCOLENV_BLK.

Table 8-27 Contents of UCOLENV_BLK

Member name Length (bytes) Attribute Area name Defined by Description
interface_blk 56 UINTERFACE_
BLK
Interface block Caller Import system definition information
reflect_blk 96 UREFLECT_BLK Import control block Caller Source database update information in import data
auth_id 8 char Authorization identifier Caller Authorization identifier used for importing into the target database
tbl_id 30 char Table identifier Caller Table identifier used for importing into the target database
reserve 2 char Reserved Caller N/A

UINTERFACE_BLK, UREFLECT_BLK
The structures of UINTERFACE_BLK and UREFLECT_BLK are the same as for an import information editing UOC routine, but their contents and usage are different. Table 8-28 Contents of UINTERFACE_BLK shows the contents of UINTERFACE_BLK, and Table 8-29 Contents of UREFLECT_BLK shows the contents of UREFLECT_BLK.

Table 8-28 Contents of UINTERFACE_BLK

Member name Length (bytes) Attribute Area name Defined by Description
auth_id 8 char Authorization identifier Caller 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 Caller 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 * N/A N/A Not used with a column data editing UOC function.
inherinf2 4 long N/A N/A Not used with a column data editing UOC function.
stopinf 4 long N/A N/A Not used with a column data editing UOC function.

Table 8-29 Contents of 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):

INSERT
INSERT statement

UPDATE
UPDATE statement
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

When the source database is a HiRDB:
Source database's HiRDB identifier

When the source database is a mainframe (XDM/DS, PDM2 E2, or RDB1 E2):
Source database's subsystem ID
infflag1 1 unsigned char Flag 1 Caller Not used.

HDS_NULL_FLAG (0x00)
Fixed value
infflag2 1 unsigned char Flag 2 Caller Not used.

HDS_NULL_FLAG (0x00)
Fixed value
infflag3 1 unsigned char Flag 3 Caller Not used.

(0x00)
Fixed value
reserve1 1 char N/A N/A (For boundary adjustment)
infflag4 4 long Flag 4 Caller Not used.

(0x00)
Fixed value

UCOLUMN_BLK
This block stores information about the column data. For the pre-edit import column information, the caller stores information about the update data in the update information and passes it to the column data editing UOC routine. For the post-edit import column information, the information edited by the UOC routine is stored. The UOC routine must store the data type, column option (optional), column data length, and data obtained after editing in the area indicated by the data address in the post-edit import column information. The following table shows the contents of UCOLUMN_BLK.

Table 8-30 Contents of UCOLUMN_BLK

Member name Length (bytes) Attribute Area name Pre-edit Defined by Post-edit Defined by Description
colname 30 char Column name Caller Caller

Pre-edit import column information:
Source table's column name is set.

Post-edit import column information:
Target table's column name is set.
coltype 1 unsigned char Column type Caller Caller Source column's column data type is set as the pre-edit import column information.
After editing, set the column data type as the post-edit import column information.
Use the same mnemonic as the import information editing interface (BLOB, BINARY, UNPACK, and ADT (SGMLTEXT, FREEWORD, XML) data type cannot be specified for the post-edit import column information).
coloption 1 unsigned char Column option Caller Caller Source column's column option is set as the pre-edit import column information.
After editing, set the column option as the post-edit import column information.
The following options can be set:

HDS_COL_NOOPT (0x00):
No option

HDS_COL_NULL (0x01):
Null data

HDS_COL_ARRAY (0x04):
Array column (the array column option is not permitted in the post-edit import column information)
elementnum 4 union Valid element number in array column Caller N/A If an array is specified as the column option in the pre-edit import column information, the valid element number of the array column is set (this information cannot be set in the post-edit import column information).
mltcolkind 1 unsigned char N/A N/A N/A Not used with a column data editing UOC routine.
adtfunc 1 unsigned char ADT column import method Caller N/A One of the following values is set as the abstract data type linkage method:

0x00
Other than abstract data type

HDS_ADTREP_NORM(0x01)
Constructor function import method
charset 1 char Character set type Caller N/A Character set type of the column data that is to be passed to the UOC routine
Do not change the character set type before or after editing. If the character set type is changed, Datareplicator ignores the edited character set type and resumes processing using the character set in effect before editing.

When no character set is specified:
X'00' (HDS_CSET_DEFAULT)

When a character set (EBCDIK) is specified:
X'01' (HDS_CSET_EBCDIK)
reserve1 1 char N/A N/A N/A (For boundary adjustment)
collen 4 long Column data length Caller Caller Column data length. For details, see Table 8-31 Specification rules for the column data length.
If the column option is null data, 0 is set in the pre-edit import column information. If null data is set as the column option in the post-edit import column information, there is no need to set the column data length, regardless of the data type.
dataptr 4 union Data address Caller N/A

Pre-edit import column information:
Address of the pre-edit column data is set.
If the column option is null data, NULL is set as the data address.
dataptr 4 union Data address Caller N/A

Post-edit import column information:
The address of the column data editing area is set. The column data editing area has a size of 32002 bytes. The column data editing UOC routine must place the edited data in the area indicated by this address. For the address type, use the same mnemonic as the import information editing interface.

Table 8-31 Specification rules for the column data length

Before/after conversion
Column data type
Pre-edit import column information Post-edit import column information Remarks
Specified Specified information Required Specified information
NCHAR Yes Pre-edit data length [characters] Yes Post-edit data length [characters] N/A
CHAR
MCHAR
UNPACK
Yes Pre-edit data length [bytes] Yes Post-edit data length [bytes] UNPACK type is not permitted for the post-edit import column data.
NVARCHAR
VARCHAR
MVARCHAR
No N/A No N/A Edit the pre-edit data using the real length stored in the first 2 bytes of the data area. For the post-edit data, set its real length in the first 2 bytes of the data area.
If the column data type is NVARCHAR, set the length in characters; if it is VARCHAR or MVARCHAR, set the length in bytes.
DECIMAL Yes

Leading 2 bytes
Precision (total number of digits)

Trailing 2 bytes
Scaling (decimal places)
Yes

Leading 2 bytes
Precision (total number of digits)

Trailing 2 bytes
Scaling (decimal places)
The maximum precision is 38 in the following cases:
  • The target HiRDB version is 08-04 or later.
  • The target DBMS is Oracle or SQL Server.
In all other cases, the maximum precision is 29.
TIMESTAMP Yes

Leading 2 bytes
Data length before editing
7 + [Figure] p/2 [Figure] [bytes]

Trailing 2 bytes
Scaling (decimal places)
Yes

Leading 2 bytes
Data length after editing
7 + [Figure] p/2 [Figure] [bytes]

Trailing 2 bytes

Scaling (decimal places)
p is a numeric value indicating the scaling (decimal places).
Other No N/A No N/A For the data length, see the HiRDB data format.
(c) Status

You can set a status value in the event the column data editing UOC routine returns control with an error. The specified status value will be displayed in the error message when control is returned to Datareplicator.

(d) Return value

Set the return value when control is returned to the caller. The following table shows the return values that can be set by a column data editing UOC routine.

Table 8-32 Return values from hds_ucoleditX()

Status Code Mnemonic Processing after control is returned
Normal termination 0 HDS_RET_NORM Resumes processing.
Error detected (unresumable level) Other than 0 HDS_RET_ERR Outputs a message at the caller, and then cancels import processing.

(2) Header files used with a column data editing UOC routine

The header files used with a column data 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 a column data editing UOC routine.

Table 8-33 Header files for the column data editing UOC

Filename Description Members associated with the column data editing UOC routine
hds_ucommon.h Structures and mnemonic codes common to column data editing UOC routines
  • UINTERFACE_BLK
  • Mnemonics for the return value
hds_ureflect.h Structure and mnemonics for the column data editing UOC routine
  • UCOLENV_BLK
  • UREFLECT_BLK
  • Mnemonics for UREFLECT_BLK
  • UCOLUMN_BLK
  • Mnemonics for the data type
  • Mnemonics for the data address