Fetch and insert into datetime host variables

When an application uses a datetime host variable to fetch or insert a DATETIME value, Informix® ESQL/C must find a valid qualifier in the datetime host variable. Informix 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, Informix 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 Informix ESQL/C dtextend() function.

  • When the dt_qual field does not contain a valid qualifier, Informix ESQL/C takes different actions for a fetch and an insert:
    • For a fetch, Informix 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 Informix ESQL/C uses the qualifier of the DATETIME column.

    • For an insert, Informix ESQL/C cannot perform the insert or update operation.

      Informix 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.