CLOB scalar function

The CLOB function returns a CLOB representation of a character string or vector type.

Read syntax diagramSkip visual syntax diagramCLOB(character-string-expressionvector-expression,integer)

The schema is SYSIBM.

In a Unicode database, if a supplied argument is a graphic string, it is first converted to a character string data type before the function is executed.

Character string to CLOB

character-string-expression
An expression that returns a value that is a character string. The expression cannot be a character string defined as FOR BIT DATA (SQLSTATE 42846). In a Unicode database, if a supplied argument is a graphic string, it is first converted to a character string data type before the function is run.
integer
An integer value that specifies the length attribute of the resulting CLOB data type. If the character-string-expression string unit is OCTETS, then the value must be between 0 and 2 147 483 647. If the character-string-expression string unit is CODEUNITS32, the value must be between 0 and 536 870 911. If a value for integer is not specified, the length of the result is the same as the length of the first argument.

The result of the function is a CLOB in the string units of the character-string-expression. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Vector to CLOB

vector-expression
An expression that returns a value that is a built-in vector data type.
integer
An integer value that specifies the length attribute of the resulting CLOB data type in the default string units. If the default string units is SYSTEM, then the value must be between 0 and 2 147 483 647. If the default string unit is CODEUNITS32, then the value must be between 0 and 536 870 911. If a value for integer is not specified, then the length attribute of the result is determined by the following values:
  • The dimension (D) of the vector-expression.
  • The coordinate type of the vector-expression.
If the coordinate type is INT8, then the length attribute is calculated by using D*5+1.
If the coordinate type is FLOAT32, then the length attribute is calculated by using D*16+1.

The result of the function is a CLOB in the default string units. If the serialized length of the vector-expression is greater than the length attribute of the result, an error is returned (SQLSTATE 22001). If the argument can be null, then the result can be null; if the argument is null, then the result is the null value.