Fetch and insert into datetime host variables
When an application uses a datetime host variable to fetch
or insert a DATETIME value, HCL
OneDB™ ESQL/C must
find a valid qualifier in the datetime host variable. HCL
OneDB ESQL/C takes
one of the following actions, based on the value of the dt_qual field
in the dtime_t structure that is associated with the host variable:
- When the dt_qual field contains a valid qualifier, HCL
OneDB ESQL/C extends
the column value to match the dt_qual qualifier.
Extending is the operation of adding or dropping fields of a DATETIME value to make it match a given qualifier. You can explicitly extend DATETIME values with the SQL EXTEND function and the HCL OneDB ESQL/C dtextend() function.
- When the dt_qual field does not contain a valid qualifier, HCL
OneDB ESQL/C takes
different actions for a fetch and an insert:
- For a fetch, HCL
OneDB ESQL/C uses
the DATETIME column value and its qualifier to initialize the datetime host
variable.
Zero (
0
) is an invalid qualifier. Therefore, if you set the dt_qual field to zero, you can ensure that HCL OneDB ESQL/C uses the qualifier of the DATETIME column. - For an insert, HCL
OneDB ESQL/C cannot
perform the insert or update operation.
HCL OneDB ESQL/C sets the SQLSTATE status variable to an error-class code (and SQLCODE to a negative value) and the update or insert operation on the DATETIME column fails.
- For a fetch, HCL
OneDB ESQL/C uses
the DATETIME column value and its qualifier to initialize the datetime host
variable.