Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Reading values into host variables or a descriptor area

The following rules apply if values from table columns or output parameters of a routine are stored in a host variable or in a descriptor area (SELECT...INTO, EXECUTE...INTO, FETCH...INTO, INSERT...RETURN INTO, CALL):

  • Values from atomic columns, multiple columns with the dimension 1 or output parameters of a procedure can be stored in an atomic host variable, a vector with one element, or in an item descriptor.

  • Aggregates from multiple columns with a dimension d > 1 can be stored in a vector with d elements or in d sequential item descriptors.

  • If the value to be transferred is a NULL value, the indicator variable or item descriptor field INDICATOR, as appropriate, is set to -1. If no indicator variable has been specified for a host variable, an error message is issued.

  • Depending on the data type, data-type-specific rules which are contained below also apply.

Strings

You can read an alphanumeric column value or an alphanumeric output parameter of a procedure into an alphanumeric host variable or item descriptor. You can read a national column value or a national output parameter of a procedure into a national host variable or item descriptor with a national data type. The following rules apply:

  • If the target data type is CHAR or NCHAR and the length of the value is smaller than the length of the target data type, the value is padded on the right with blanks.

  • If the target data type is CHAR or NCHAR and the length of the value is greater than the length of the target data type, the value is truncated from the right to the length of the target data type and a warning is issued. The indicator variable (if specified) or item descriptor field INDICATOR, as appropriate, is set to the original length of the column value.

  • If the target data type is VARCHAR or NVARCHAR and the length of the value is greater than the maximum length of the target data type, the value is truncated from the right to the maximum length of the target data type and a warning is issued. The indicator variable (if specified) or item descriptor field INDICATOR, as appropriate, is set to the original length of the column value.

Numeric values

You can read a numeric column value or a numeric output parameter of a procedure into a numeric host variable or item descriptor. If the numeric data types are not the same, the value is converted to the target data type. The following rules apply:

  • If the number of digits to the right of the decimal point of the value is too large for the target data type, the value is rounded.

  • If the value is too large for the target data type, the value is not entered and an error message is issued.

Time values

You can only read a column value with a time data type or an output parameter of a procedure with a time data type into a host variable or item descriptor of the same data type:

  • a date into a DATE host variable or item descriptor

  • a time into a TIME host variable or item descriptor

  • a time stamp into a TIMESTAMP host variable or item descriptor