Fetch or insert into an mi_interval variable

When a DataBlade® API module uses an mi_interval variable to fetch or insert an INTERVAL value, the DataBlade API must find a valid qualifier in the mi_interval variable.

The DataBlade API takes one of the following actions, based on the value of the in_qual field the intrvl_t structure that is associated with the variable:
  • When the in_qual field contains a valid qualifier, the DataBlade API 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, the DataBlade API 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, the DataBlade API 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, the DataBlade API 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, the DataBlade API uses the INTERVAL column value and its qualifier to initialize the mi_interval 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, the DataBlade API cannot perform the insert or update operation.

      The DataBlade API 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.