Example: Using a Multidimensional ARRAY in a Parameter Definition - Teradata Vantage - Analytics Database

SQL Data Definition Language Syntax and Examples

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-22
dita:mapPath
jco1628111346878.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
mdr1472255012272
lifecycle
latest
Product Category
Teradata Vantage™

This example uses a multidimensional ARRAY type to define an INTEGER element type.

The first step is to create the an appropriate multidimensional ARRAY type. The first CREATE TYPE request uses Oracle-compatible syntax to define the ARRAY type phonenumbers_ary.

     CREATE TYPE 3d_array
     AS VARRAY (1:5)(1:7)(1:20) OF INTEGER;

The second CREATE TYPE request uses Teradata-ANSI style syntax to define the same type.

     CREATE TYPE 3d_array 
     AS INTEGER ARRAY[1:5][1:7][1:20];

The following CREATE FUNCTION request creates the function array_udf using an SQL parameter style and uses the multidimensional ARRAY type 3d_array as the data type of its single parameter, a1.

     CREATE FUNCTION array_udf( 
       a1 3d_array)  
     RETURNS VARCHAR(100)
     NO SQL
     PARAMETER STYLE SQL
     DETERMINISTIC
     LANGUAGE C
     EXTERNAL NAME 'CS!array_udf!array_udf.c!F!my_array_udf';
void my_array_udf (	
     ARRAY_HANDLE   *ary_handle, 
     VARCHAR_LATIN  *result,
     int            *indicator_ary,
     int            *indicator_result,
     char           sqlstate[6],
     SQL_TEXT       extname[129],
     SQL_TEXT       specific_name[129],
     SQL_TEXT       error_message[257])	
{
/* body function */
}

The following CREATE FUNCTION request creates the same function, but uses the TD_GENERAL parameter style.

     CREATE FUNCTION array_udf ( 
       a1 3d_array)  
     RETURNS VARCHAR(100)
     NO SQL
     PARAMETER STYLE TD_GENERAL
     DETERMINISTIC
     LANGUAGE C
     EXTERNAL NAME 'CS!array_udf!array_udf.c!F!my_array_udf';
void my_array_udf (
     ARRAY_HANDLE   *ary_handle, 
     VARCHAR_LATIN  *result, 
     	char           sqlstate[6])
{ /* body function */
}