Fetch and insert into interval host variables

When an application uses an interval host variable to fetch or insert an INTERVAL value, must find a valid qualifier in the interval host variable. takes one of the following actions, based on the value of the in_qual field of the intrvl_t structure that is associated with the host variable:
  • When the in_qual field contains a valid qualifier, checks it for compatibility with the qualifier from the INTERVAL column value.

    The two qualifiers are compatible if they belong to the same interval class: either year to month or day to fraction. If the qualifiers are incompatible, sets the SQLSTATE status variable to an error-class code (and SQLCODE is set to a negative value) and the select, update, or insert operation fails.

    If the qualifiers are compatible but not the same, extends the column value to match the in_qual qualifier. Extending is the operation of adding or dropping fields within one of the interval classes of an INTERVAL value to make it match a given qualifier. You can explicitly extend INTERVAL values with the invextend() function.

  • When the in_qual field does not contain a valid qualifier, takes different actions for a fetch and an insert:
    • For a fetch, if the in_qual field contains zero or is not a valid qualifier, uses the INTERVAL column value and its qualifier to initialize the interval host variable.
    • For an insert, if the in_qual field is not compatible with the INTERVAL column or if it does not contain a valid value, cannot perform the insert or update operation.

      sets the SQLSTATE status variable to an error-class code (and SQLCODE is set to a negative value) and the update or insert operation on the INTERVAL column fails.