17.10 - Example: Concatenating Two 1-D ARRAY Values - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

This example takes two 1-D ARRAY values of the same data type and concatenates them together. PhoneNum and OldPhoneNum are columns in the employee_info table, and both columns have the same 1-D ARRAY data type.

/* The following select statement concatenates the current value in "PhoneNum" with the value in "OldPhoneNum". */
/* Assume one row in table employee_info contains the following value for "PhoneNum": 
PhoneNum[1] = '6197211000'
PhoneNum[2] = '6197221000'
PhoneNum[3] = '6197231000'
Also, assume one row in table employee_info contains the following value for "OldPhoneNum": 
OldPhoneNum[1] = '8582001000'
OldPhoneNum[2] = '8582002000'
OldPhoneNum[3] = '8582003000'
*/
SELECT ARRAY_CONCAT(PhoneNum, OldPhoneNum)
FROM employee_info;
/* Result value is the following:
PhoneNum[1] = '6197211000'
PhoneNum[2] = '6197221000'
PhoneNum[3] = '6197231000'
PhoneNum[4] = '8582001000'
PhoneNum[5] = '8582002000'
PhoneNum[6] = '8582003000'
*/

The following shows the same query using method-style syntax:

SELECT PhoneNum.ARRAY_CONCAT(OldPhoneNum)
FROM employee_info;