Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Create the Record Schema with PutDODA

The definition of each of the fields comprising a record can be stored in the data file itself if the data file has not disabled RESOURCE support. The advantage of storing the schema is that applications can use this information without any outside information. Further, c-tree can use field numbers to specify key segments if the schema is stored in the file, enabling flexible key segment definitions.

An application can store the schema in a file directly by use of the PutDODA() function. A DODA is a data object definition array. Each element of the array is comprised of a structure of type DATOBJ which is typedefed in ctport.h. Only three of the first four fields of the DATOBJ are required for the PutDODA() call. DATOBJ is defined as follows:

typedef struct {

pTEXT fsymb; /* ptr to symbol name */

pTEXT fadr; /* adr of field in record buffer */

UCOUNT ftype; /* type indicator */

UCOUNT flen; /* field length in bytes */

...

} DATOBJ;

  • fsymb points to a symbolic name for the field and should not be NULL.
  • fadr is not used by the c-tree PutDODA() call and its value is ignored.
  • ftype is one of the field types specified in the “Field Types” table.
  • flen is set to the field’s length in bytes for fixed length fields, or the known maximum for varying length fields with a known maximum length in bytes, or zero for varying length fields without known maximum. If the field type has an intrinsic length, which is true for types CT_CHAR through CT_DFLOAT, a zero length is automatically replaced by the intrinsic length.

Given a data record with structure:

struct {

TEXT zipcode[10]; /* Zip code */

LONG ssn; /* social security # */

TEXT name[50]; /* name */

} DATA_FORMAT;

The corresponding DODA would be defined as:

DATOBJ doda[] = {

{"ZipCode", NULL, CT_FSTRING, 10},

{"SocialSecurity", NULL, CT_INT4},

{"Name", NULL, CT_STRING,50}

};

Note: zipcode is considered to take up a fixed space in the record, CT_FSTRING, while name takes up a variable amount of space, CT_STRING, up to a maximum of 50 bytes.

Notes when using a DATOBJ with the r-tree Report Generator

  • The r-tree Report Generator requires the first four fields of the DATOBJ structure to be defined and the second field of the DATOBJ structure, fadr, must be filled-in.
  • For the r-tree Report Generator report() function the DODA is terminated by an entry of the form:

{NULL,NULL,0,0,-1}

A DODA in this form can be used by PutDODA(), however, the terminating entry shown above is not counted as one of the fields unless accounted for in the last parameter of the PutDODA() function. See PutDODA for details.

TOCIndex