Argument Type and Rules | ARRAY Constructor | Teradata Vantage - Argument Type and Rules - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
zsn1556242031050.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantageā„¢

Expressions passed to the ARRAY constructor must be able to be implicitly converted to the data type of the element type of the array_name array. Existing implicit CAST functionality, such as casting from CHAR to Timestamp or Timestamp to DATE, is supported for the ARRAY constructor expression.

The ARRAY constructor expression accepts zero or more arguments. If there are zero arguments, the ARRAY constructor initializes an empty ARRAY type value and sets all the element values of the array to an uninitialized state if the ARRAY data type was created without the DEFAULT NULL clause. If the ARRAY data type was created with a DEFAULT NULL clause, then the ARRAY constructor initializes all the element values of the array to null. Note that if you try to access an array element that is in an uninitialized state, you will get an error.

You can pass up to n arguments to the ARRAY constructor expression, where n is the declared size of the ARRAY data type. For a one-dimensional ARRAY type, the ARRAY constructor fills the elements of the array with the argument values sequentially starting from the first element, in the order that the arguments are passed in. For a multidimensional ARRAY type, pass the arguments to the ARRAY constructor expression in row-major order because elements in a multidimensional array are filled in row-major order.

If the number of arguments are less than the number of elements in the array, then the remaining elements for which an argument value is not provided are set to an uninitialized state. However, if the ARRAY data type was created with the DEFAULT NULL clause, then those elements are set to null.

A constructor method for a UDT may not accept more than 128 arguments; however, this limit does not apply to ARRAY data types. The number of arguments that you can specify for the ARRAY constructor is limited only by the maximum number of elements that you can define for the ARRAY type or 2559, whichever comes first.

Note that if the element type of the array is a variable-length type, and if the value passed to initialize the element is larger than the maximum size of the element type, Teradata Database automatically truncates the passed value to the maximum size of the element type. This truncation behavior occurs with transaction processing in Teradata session mode only. In ANSI session mode, Teradata Database does not truncate the passed value, and returns an error instead. This behavior is identical to that of distinct and structured UDTs.