Example: Using OEXTEND to Fill the End of a Constructed ARRAY with NULL Elements - Advanced SQL Engine - Teradata Database

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
tpf1598412463935.ditamap
dita:ditavalPath
tpf1598412463935.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following example shows how you can use the OEXTEND method to fill the end of a constructed ARRAY with NULL elements so that these elements are no longer in an uninitialized state. This can be helpful when the ARRAY may be used as an argument to another system function or operator.

CREATE TYPE myarray AS VARRAY(5) OF INTEGER;
CREATE TABLE mytab (id INTEGER, ary myarray);
/* Populate the first 3 elements. The last 2 elements are uninitialized. */
INSERT INTO mytab VALUES (1, NEW myarray(1,2,3));
/* Fill the last 2 elements with NULLs. */
UPDATE mytab
SET ary = ary.OEXTEND(2)
WHERE id = 1;
SELECT ary FROM mytab;

The following is the result of the query.

(1,2,3,NULL,NULL)