Scalable Database Server, HiRDB Version 8 Command Reference
This section presents an example of table reorganization and the table unload operation using a UOC.
The example of UOC coding shown here is provided as a sample database. It is stored in the directory $PDDIR/sample/sampleUOC.
During table reorganization, this example deletes data whose database registration date is year 2001 or earlier.
CREATE TABLE MEMBVER_DIRECTORY (MEMBER_NUMBER INTEGER,
MEMBER_NAME NCHAR(20),
MEMBER_ADDRESS NVARCHAR(100),
JOINED_DATE_AND_TIME DATE NOT NULL WITH DEFAULT);
pdrorg -k rorg -t MEMBVER_DIRECTORY control-information-file |
unload unload-data-file-name uoc_lib=library-name unlduoc entry=old_data_delete |
#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:
/*
|
This example edits BLOB data in CSV format when a table is unloaded. The example creates UOC data files based on one data item per file.
CREATE TABLE IMAGE_TBL
(COL1 INTEGER NOT NULL,
COL2 CHAR(20) NOT NULL,
COL3 INTEGER NOT NULL,
COL4 CHAR(5) NOT NULL,
COL5 BLOB(100K) IN (LOB_AREA) NOT NULL)
IN DATA_AREA;
pdrorg -k unld -j -t IMAGE_TBL control-information-file |
unload (uoc) uoc_lib=library-name param='/usr/tmp/lob,/tmp/uoc_file' unlduoc entry=blob_file_create |
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <pdutluoc.h>
#define INT 0xf0 /* INTEGER */
#define CHAR 0xc4 /* CHAR */
#define BLOB 0x92 /* BLOB */
void blob_file_create (
UTL_UOC_INF *uocinf /* A(UOC interface area) */
) {
static char token[] = ","; /* parameter token */
static char prefix[40]; /* path name prefix */
static char filename[80]; /* CSV file name */
static char *buff = NULL; /* row edit buffer */
static int counter = 0; /* row counter */
static int file_id = 0; /* CSV file file ID */
int lobfid; /* BLOB file */
int leng; /* total length */
int int_len; /* INTEGER length */
int i; /* counter for column */
int rc; /* return code */
int *nagasa; /* BLOB size */
void *blobadr; /* A(BLOB data) */
char *wkadr; /* work address */
UTL_UOC_DATA_BUF *addr_list; /* A(data address list) */
UTL_UOC_COLUMN_INFO *col_inf; /* A(column information) */
char *sepachr = ","; /* separator character */
char *linechr = "\n"; /* line field character */
char dmyname[16]; /* temporary name */
char blobfile[128]; /* BLOB file name */
switch(uocinf->req_cd){
case UTL_UOC_START:
/*
|
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.