Example: Scalar Function with Parameter Style TD_GENERAL - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
rin1593638965306.ditamap
dita:ditavalPath
rin1593638965306.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

Here is a code excerpt that shows how to declare a scalar function that uses parameter style TD_GENERAL:

/*****  C source file name: substr.c  *****/
   
#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include <string.h>
  
void udf_scalar_substr( VARCHAR_LATIN *inputString,
                        INTEGER       *start,
                        VARCHAR_LATIN *result,
                        char          sqlstate[6])
{
     ...
}

For a complete example of the scalar function, see Example: Basic Scalar Function.

The corresponding CREATE FUNCTION statement looks like this:

CREATE FUNCTION udfSubStr
  (inputString VARCHAR(512),
   start       INTEGER)
RETURNS VARCHAR(512)
LANGUAGE C
NO SQL
EXTERNAL NAME 'CS!substr!udfsrc/substr.c!F!udf_scalar_substr'
PARAMETER STYLE TD_GENERAL;