DB2 Version 9.7 for Linux, UNIX, and Windows

TRIM_ARRAY scalar function

Read syntax diagramSkip visual syntax diagram
>>-+-TRIM_ARRAY-+--(--array-variable----,--numeric-expression----)-><
   '-ARRAY_TRIM-'                                                    

The schema is SYSIBM.

The TRIM_ARRAY function deletes elements from the end of an array.

array-variable
An SQL variable, SQL parameter, or global variable of an ordinary array type, or a CAST specification of a parameter marker to an ordinary array type. An associative array data type cannot be specified (SQLSTATE 42884).
numeric-expression
Specifies the number of elements trimmed from the end of the array. The numeric-expression can be of any numeric data type with a value that can be cast to INTEGER. The value of numeric-expression must be between 0 and the cardinality of array-variable (SQLSTATE 2202E).

The function returns a value with the same array type as array-variable but with the cardinality reduced by the value of INTEGER(numeric-expression). The result can be null; if either argument is null, the result is the null value.

Rules

The TRIM_ARRAY function is not supported for associative arrays (SQLSTATE 42884).

The TRIM_ARRAY function can only be used on the right side of an assignment statement in contexts where arrays are supported (SQLSTATE 42884).

Examples