The intoasc() function
The intoasc() function converts the field values of an interval variable to an ASCII string that conforms to the ANSI SQL standard.
Syntax
mint intoasc(invvalue, outbuf)
intrvl_t *invvalue;
char *outbuf;
- invvalue
- A pointer to the initialized interval variable to convert.
- outbuf
- A pointer to a buffer to contain the ANSI-standard INTERVAL string for the value in invvalue.
Usage
The intoasc() function converts the digits of the fields in the interval variable to their character equivalents and copies them to the outbuf character string with delimiters (hyphen, space, colon, or period) between them. You must initialize the interval variable in invvalue with the qualifier that you want the character string to have.
The
character string does not include the qualifier or the parentheses
that SQL statements use to delimit an INTERVAL literal. The outbuf string
conforms to ANSI SQL standards. It includes one character for each
delimiter (hyphen, space, colon, or period) plus fields with the following
sizes.
- Field
- Field size
- Leading field
- As specified by precision
- Fraction
- As specified by precision
- All other fields
- Two digits
An interval value with the day(5)
to fraction(5) qualifier produces the maximum length of output.
The string equivalent contains 16 digits, 4 delimiters, and the null
terminator, for a total of 21 bytes:
DDDDD HH:MM:SS.FFFFF
If you do not initialize the qualifier of the interval variable, the intoasc() function returns an unpredictable value, but this value does not exceed 21 bytes.
Return values
- 0
- The conversion was successful.
- <0
- The conversion failed.