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 */
}