Examples | OEXTEND Function| Teradata Vantage - Example: Query a 1-D ARRAY Data Type and Table using OEXTEND - Teradata Vantage - Analytics Database

SQL Data Types and Literals

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
uds1628112204571.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
exs1472253032394
lifecycle
latest
Product Category
Teradata Vantageā„¢

Consider the following one-dimensional ARRAY data type and table.

CREATE TYPE phonenumbers AS VARRAY(20) OF CHAR(10);
CREATE TABLE employee_info (eno INTEGER, phonelist phonenumbers);

The table is populated with the following values:

/* The first 2 elements are populated; the rest are uninitialized. */
INSERT INTO employee_info VALUES (1, 
   phonenumbers('1112223333', '6195551234'));
/* Empty ARRAY instance */
INSERT INTO employee_info VALUES (2, 
   phonenumbers());
/* Update empty ARRAY instance such that element 3 is set to a value;
   Then elements 1 and 2 are set to NULL, the rest are uninitialized */
UPDATE employee_info
SET phonelist[3] = '8584850000'
WHERE id = 2;

The following query extends the phonelist array with a single NULL element.

SELECT eno, phonelist.OEXTEND()
FROM employee_info;

The following is the result of the query.

ENO         phonelist.OEXTEND()
---         -------------------
 1           ('1112223333', '6195551234',NULL)
 2           (NULL,NULL,'8584850000',NULL)

The following query extends the phonelist array with three NULL elements.

SELECT eno, phonelist.OEXTEND(3)
FROM employee_info;

The following is the result of the query.

ENO         phonelist.OEXTEND(3)
---         --------------------
 1           ('1112223333', '6195551234',NULL,NULL,NULL)
 2           (NULL,NULL,'8584850000',NULL,NULL,NULL)

The following query extends the phonelist array with two copies of element 1.

SELECT eno, phonelist.OEXTEND(2,1)
FROM employee_info
WHERE eno = 1;

The following is the result of the query.

ENO         phonelist.OEXTEND(2,1)
---         ----------------------
 1           ('1112223333', '6195551234', '1112223333', '1112223333')

The following is the same query using function-style syntax.

SELECT eno, OEXTEND(phonelist,2,1)
FROM employee_info
WHERE eno = 1;