コントラクト関数でFNC_TblOpGetBaseInfoを使用する方法を以下に示します。
int tblopudt_metain_contract( INTEGER *Result, int *indicator_Result, char sqlstate[6], SQL_TEXT extname[129], SQL_TEXT specific_name[129], SQL_TEXT error_message[257]) { FNC_TblOpColumnDef_t *oCols; FNC_TblOpColumnDef_t *iCols; UDT_BaseInfo_t *udtBaseInfo; Stream_Fmt_en format; InputInfo_t *icolinfo; int incount, outcount , ocolcount; int i,j, totalcols; char mycontract[] = "this is my contract... this is my contract... this is my contract..."; char msg[500] = ""; FNC_TblOpGetStreamCount(&incount, &outcount); if(incount == 0) { SetError("U0003", "mift1 requires number of input streams to be > 0."); return -1; } icolinfo = FNC_malloc (incount * sizeof(InputInfo_t)); totalcols = 0; for(i=0; i < incount; i++) { icolinfo[i].colcount = FNC_TblOpGetColCount(i, ISINPUT); totalcols += icolinfo[i].colcount; icolinfo[i].iCols = FNC_malloc(TblOpSIZECOLDEF(icolinfo[i].colcount)); TblOpINITCOLDEF(icolinfo[i].iCols, icolinfo[i].colcount); FNC_TblOpGetColDef(i, ISINPUT, icolinfo[i].iCols); /* Retreive UDT metadata info for each column and write to trace table */ iCols = icolinfo[i].iCols; icolinfo[i].baseColInfo = FNC_malloc(sizeof(UDT_BaseInfo_t) * iCols->num_columns); FNC_TblOpGetBaseInfo(iCols,icolinfo[i].baseColInfo); } /* Allocate space for columns. */ oCols = (FNC_TblOpColumnDef_t *)FNC_malloc( TblOpSIZECOLDEF(totalcols) ); memset(oCols, 0 , TblOpSIZECOLDEF(totalcols) ); oCols->num_columns = totalcols; oCols->length = TblOpSIZECOLDEF(totalcols) - (2 * sizeof(int)) ; TblOpINITCOLDEF(oCols, totalcols); ocolcount = 0; /* Copy input columns to output columns. */ for(j=0; j < incount; j++) { iCols = icolinfo[j].iCols; for(i=0;i < iCols->num_columns;i++) { oCols->column_types[ocolcount].datatype = VARCHAR_DT; oCols->column_types[ocolcount].charset = LATIN_CT; oCols->column_types[ocolcount].size.length = 32; ocolcount++; } } FNC_TblOpSetContractDef(mycontract, strlen(mycontract)+1); /* Define output columns. */ FNC_TblOpSetOutputColDef(0, oCols); format = INDICFMT1; FNC_TblOpSetFormat("RECFMT", 0, ISINPUT, &format, sizeof(format)); FNC_TblOpSetFormat("RECFMT", 0, ISOUTPUT, &format, sizeof(format)); FNC_free(oCols); for(i=0; i < incount; i++) { FNC_free(icolinfo[i].iCols); FNC_free(icolinfo[i].baseColInfo); } FNC_free(icolinfo); *Result = 1; }