Examples | OFIRST Function| Teradata Vantage - 17.10 - Example: Query a 1-D ARRAY Data Type and Table using OFIRST - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Data Types and Literals

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

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, 

The following query returns the lowest subscript value in the phonelist array.

SELECT eno, phonelist.OFIRST()
FROM employee_info;

The following is the result of the query.

ENO         phonelist.OFIRST()
---         ------------------
 1           1
 2           1