Specifying Nonstandard Include Files - 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™

If an external stored procedure includes a nonstandard header file, the EXTERNAL clause in the CREATE PROCEDURE statement must specify the name and path of the header file.

Consider the following external stored procedure that includes the header file rtypes.h:

/*****  C source file name: get_r.c  *****/

#define SQL_TEXT Latin_Text
#include <sqltypes_td.h>
#include "rtypes.h"

void xsp_getr( VARCHAR_LATIN *region,
               char           sqlstate[6])
{
     ...
}

Here is an example of CREATE PROCEDURE that specifies the name and path of the nonstandard header file:

CREATE PROCEDURE GetRegionXSP (INOUT region VARCHAR(64))
LANGUAGE C
NO SQL
EXTERNAL NAME
'CI!rtypes!xsp_home/rtypes.h!CS!get_r!xsp_home/get_r.c!F!xsp_getr'
PARAMETER STYLE TD_GENERAL;

where:

This part of the string that follows EXTERNAL NAME … Specifies …
! a delimiter.
C that the header file is obtained from the client.
I that the information between the following two sets of delimiters identifies the name and location of an include file (.h).
rtypes the name, without the file extension, of the header file.
xsp_home/rtypes.h the path and name of the header file on the client.
C that the source is obtained from the client.
S that the information between the following two sets of delimiters identifies the name and location of a C or C++ function source file.
get_r the name, without the file extension, that the server uses to compile the source.
xsp_home/getregion.c the path and name of the source file.
F that the information after the next delimiter identifies the C or C++ function name.
xsp_getregion the C or C++ function name.

For more information on installing libraries, see the information about CREATE PROCEDURE in Teradata Vantage™ - SQL Data Definition Language Detailed Topics, B035-1184.