Examples | ODELETE Function| Teradata Vantage - Example: Query a 1-D ARRAY Data Type and Table using ODELETE - 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ā„¢

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 removes all populated elements from the phonelist array, leaving all of the elements in an uninitialized state.

SELECT eno, phonelist.ODELETE()
FROM employee_info;

The following is the result of the query.

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

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

SELECT eno, ODELETE(phonelist)
FROM employee_info;