Example: Query 1-D ARRAY Data Type and Table Using OLIMIT - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

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());

The following query returns the highest possible subscript value in the phonelist array.

SELECT eno, phonelist.OLIMIT()
FROM employee_info;

The following is the result of the query.

ENO         phonelist.OLIMIT()
---         ------------------
 1           20
 2           20

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

SELECT eno, OLIMIT(phonelist)
FROM employee_info;