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

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

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

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