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:
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;
The Field Setting Structure
typedef struct astfield {
LONG fieldno; /* field number */
TEXT mode; /* set time */
} A_STFIELD, *pA_STFIELD;
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;
}