Example: Creating an Instance Method Using a Multidimensional ARRAY Type and an SQL Parameter Type - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Published
January 2021
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
ncd1596241368722.ditamap
dita:ditavalPath
hoy1596145193032.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

The following is an example of creating a UDM for a structured UDT with a single parameter which is defined using an n-D ARRAY data type. The same example is repeated in Example: Creating an Instance Method Using a Multidimensional ARRAY Type and a TD_GENERAL Parameter Type to show the DDL and function prototype with both SQL and TD_GENERAL parameter styles.

First create the structured type measures_udt.

     CREATE TYPE measures_udt AS (
       amplitud  INTEGER,
       phase     INTEGER,
       frequency INTEGER)
     INSTANCE METHOD update_measures (
       a1 source_ary)
     …
     ;

Then create the multidimensional ARRAY type source_ary.

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

Finally, create the instance method update_measures for type measures_udt with a single multidimensional ARRAY parameter.

     CREATE INSTANCE METHOD update_measures (
         a1 source_ary)  
       RETURNS INTEGER
       FOR measures_udt
       NO SQL
       PARAMETER STYLE SQL
       DETERMINISTIC
       LANGUAGE C
       EXTERNAL NAME 'CS!update_measures!update_measures.c!F!update_measures';
void update_measures (	
UDT_HANDLE     *thisUdt,
ARRAY_HANDLE   *aryval, 
INTEGER        *result,
int            *indicator_this,
int            *indicator_aryval,
int            *indicator_result,
char           sqlstate[6],
SQL_TEXT       extname[129],
SQL_TEXT       specific_name[129],
SQL_TEXT       error_message[257])
{
/* body function */
}