Example: Query a 2-D ARRAY Data Type and Table using ONEXT - 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
Publication Date
June 2022
Content Type
Data Types
SQL Reference
Publication ID
B035-1143-172K
ft:locale
en-US
ft:lastEdition
2025-11-06
dita:mapPath
uds1628112204571.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
ft:sourceId
dita
dita:id
exs1472253032394
lifecycle
latest
Product Category
Teradata Vantageā„¢

Consider the following 2-D ARRAY data type and table.

CREATE TYPE shot_ary AS VARRAY(1:50)(1:50) OF INTEGER;
CREATE TABLE seismic_table (
   id INTEGER,
   shots shot_ary);

The table is populated with the following values:

/* The first 2 elements are populated; the rest are uninitialized. */
INSERT INTO seismic_table VALUES (1, shot_ary(11, 12));
/* Empty ARRAY instance */
INSERT INTO seismic_table VALUES (2, shot_ary());
/* Update empty ARRAY instance such that element [1][3] is set to a value; Then elements [1][1] and [1][2] are set to NULL, the rest are uninitialized */
UPDATE seismic_table
SET shots[1][3] = 1133
WHERE id = 2;

The following query returns the subscript of the element subsequent to element [1][2] in the shots array.

SELECT id, shots.ONEXT(NEW arrayVec(1, 2))
FROM seismic_table;

The following is the result of the query.

ID          shots.ONEXT(NEW arrayVec(1, 2))
--          -------------------------------
 1           ?     (The element following element [1][2] is unpopulated)
 2           NEW arrayVec(1,3)

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

SELECT id, ONEXT(shots, NEW arrayVec(1, 2))
FROM seismic_table;