During table reorganization, this example deletes data whose database registration date is year 2001 or earlier.
(a) Database table definition
CREATE TABLE MEMBVER_DIRECTORY (MEMBER_NUMBER INTEGER,
MEMBER_NAME NCHAR(20),
MEMBER_ADDRESS NVARCHAR(100),
JOINED_DATE_AND_TIME DATE NOT NULL WITH DEFAULT);
(b) Command format
pdrorg -k rorg -t MEMBVER_DIRECTORY control-information-file |
(c) Contents of control information file
unload unload-data-file-name uoc_lib=library-name
unlduoc entry=old_data_delete |
(d) Example of UOC coding
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <pdutluoc.h> .......................................................1
void old_data_delete (
UTL_UOC_INF *uocinf /* A(UOC interface area) */ ...2
) {
UTL_UOC_DATA_BUF *addr_list; /* A(data address list) */
unsigned char *date_adr; /* A(DATE) */
static unsigned char cyear[2]; /* compare year */
switch(uocinf->req_cd){ .................................................3
case UTL_UOC_START:
/*----------------------------------------------------------------------*/
/* START */
/*----------------------------------------------------------------------*/
cyear[0] = 0x20; /* The 21st century */
cyear[1] = 0x01; /* (2001) */
uocinf->rtn_code = UTL_UOC_NML;
break;
case UTL_UOC_EDIT:
/*z---------------------------------------------------------------------*/
/* EDIT */
/*----------------------------------------------------------------------*/
addr_list = uocinf->data_adr;
date_adr = addr_list->data[3];
if (memcmp(date_adr,cyear,sizeof(cyear)) < 0){
uocinf->unload_flg = UTL_UOC_ROWNOPUT;
}else{
uocinf->unload_flg = UTL_UOC_ROWPUT;
} ..................................................................4
uocinf->rtn_code = UTL_UOC_NML;
break;
case UTL_UOC_END:
case UTL_UOC_TERM:
/*----------------------------------------------------------------------*/
/* END */
/*----------------------------------------------------------------------*/
uocinf->rtn_code = UTL_UOC_NML;
break;
default:
strcpy(uocinf->err_msg,"Invalid request code");
uocinf->rtn_code = UTL_UOC_ERR;
}
return;
} |
- Explanation:
- Includes the header for UOC creation that is provided by HiRDB.
- Receives the address of the UOC interface area as an argument.
- Checks the call type and executes appropriate processing.
- Checks the data (date) and sets the storage flag.