16.20 - Description - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Advanced SQL Engine
Teradata Database
March 2019
Programming Reference

SUBBITSTR extracts a bit substring from the target_arg string expression starting at the bit position specified by position_arg. For the range of bit positions for each data type, see Bit and Byte Numbering Model.

The num_bits_arg value specifies the length of the bit substring to be extracted and indicates the number of bits that the function should return. Because the return value of the function is a VARBYTE string, the number of bits returned is rounded to the byte boundary greater than the number of bits requested.

The bits returned is right-justified, and the excess bits (those exceeding the requested number of bits) are filled with zeros.

If position_arg is negative or out-of-range (meaning that it exceeds the size of target_arg), an error is returned.

If num_bits_arg is negative, or is greater than the number of bits remaining after the starting position_arg is taken into account, an error is returned.

If any of the input arguments is NULL, the function returns NULL.