Basic C/C++ Function Definition | External Stored Procedures | Teradata Vantage - Basic C/C++ Function Definition - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

Here are the basic steps you take to define an external stored procedure C/C++ function:

  1. Define the SQL_TEXT constant.

    For more information, see SQL_TEXT Definition.

  2. Include the sqltypes_td.h header file.

    For more information, see C/C++ Header Files.

  3. Include other header files that define macros and variables that the function uses.

    If the external stored procedure uses CLIv2 to directly execute SQL, include CLIv2 header files.

  4. Define the function parameter list in the order that matches the parameter passing convention specified in the CREATE PROCEDURE statement.

    For more information, see External Stored Procedure Parameter List.

  5. Implement the function and set any INOUT or OUT arguments to the appropriate value.
  6. If the function detects an error, set the:
    • sqlstate argument to an SQLSTATE exception or warning condition before the function exits.

      For more information, see Returning SQLSTATE Values.

    • error_message string to the error message text. The characters must be inside the LATIN character range. The string is initialized to a null-terminated string on input.
  7. If the function uses parameter style SQL, set the indicator_parameter arguments for the corresponding INOUT or OUT arguments.
    IF the INOUT or OUT argument is … THEN set the corresponding indicator_parameter argument to …
    NULL -1.
    not NULL 0.