Updated on 2024-06-03 GMT+08:00

Interval Type

Table 1 lists the common APIs for interval data provided by the ECPG.

Table 1 Common interval type APIs

API

Description

Remarks

interval* PGTYPESinterval_new(void)

Returns a pointer to an allocated interval variable.

This function creates an interval variable on the heap. The return value is of the interval* type.

void PGTYPESinterval_free(interval* inval)

Releases the memory that has been allocated to an interval variable.

This function releases the memory allocated to the interval* variable created by the PGTYPESinterval_new function.

interval* PGTYPESinterval_from_asc(char* str, char** endptr)

Parses an interval from its textual representation.

This function parses the input string str and returns a pointer to an allocated interval variable. Currently, ECPG parses the entire character string and does not support storing the address of the first invalid character in *endptr. You can set endptr to NULL.

char* PGTYPESinterval_to_asc(interval* span)

Converts a variable of the interval type into its textual representation.

This function converts the interval variable to which the span points into a char*.

int PGTYPESinterval_copy(interval* intvlsrc, interval* intvldest)

Copies a variable of the interval type.

This function copies the interval variable that intvlsrc points to into the variable that intvldest points to.

Examples

For details, see Examples.