Product Documentation

Automatic Data Aggregation

Previous Topic

Next Topic

AddAutoSysTimeFields()

Configure which fields the server automatically sets to the current server system time (in GMT time zone). It receives an A_STFIELDS structure that configures one or more fields to be auto updated. Each field can be set automatically to the current system time on insert, update, or on both insert and update.

NINT AddAutoSysTimeFields(COUNT datno, pA_STFIELDS defs)

Parameters:

  • datno: the data file number
  • defs: pointer to fields definition structure

The Field Definition Structure:

typedef struct astfields {

COUNT version; /* Version of this structure */

COUNT entries; /* number of entries in fields array*/

LONG pad; /* padding to ensure struct alignment */

pA_STFIELD fields; /* fields array */

} A_STFIELDS, *pA_STFIELDS;

  • verson: the version of the structure. must be set to A_STFIELDS_VERS_V01.
  • entries: the number of fields that needs to be automatically set with the system time. It must match the number of entries in the fields array.
  • fields: pointer to an array of field setting.

The Field Setting Structure

typedef struct astfield {

LONG fieldno; /* field number */

TEXT mode; /* set time */

} A_STFIELD, *pA_STFIELD;

  • fieldno: the field number in the DODA for the field that is set to auto setting with system time stamp.
  • mode: when the field gets populated. Possible values (can be ORed):

    CT_AUTOSYSTIME_CREATE 0x01 = when the record is added

    CT_AUTOSYSTIME_UPDATE 0x02 = when the record gets rewritten/updated.

Return:

NO_ERROR on Success. Otherwise error code.

Example:

IFIL vcustomer = {

"vcusti",

-1,

8,

4096,

ctSHARED | ctVLENGTH | ctTRNLOG,

1,

4096,

ctSHARED | ctTRNLOG,

ndxs,

"CustomerNumber",

"City"

};

NINT rc;

#define CUSTDAT vcustomer.tfilno /* customer data file */

pA_STFIELDS autoST_c;

autoST.verson = A_STFIELDS_VERS_V01;

autoST.entries = 2;

autoST.fields = calloc(2, sizeof(A_STFIELD));

autoST.fields[0].fieldno = 1;

autoST.fields[1].fieldno = 2;

autoST.fields[0].mode = CT_AUTOSYSTIME_UPDATE;

autoST.fields[1].mode = CT_AUTOSYSTIME_CREATE;

if ((rc = AddAutoSysTimeFields(CUSTDAT, &autoST))) {

ctrt_printf("Error: Failed to add Auto System Time fields: %d\n",

rc);

goto err_ret;

}

TOCIndex