16.20 - Overview - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
April 2020
Content Type
Programming Reference
Publication ID
B035-1147-162K
Language
English (United States)

This example extends the preceding example, Simple External Stored Procedure, by calling the FNC_CallSP library function to call the addRegion stored procedure. The external stored procedure strips off the first four characters of the region input argument and passes the result to the addRegion stored procedure, which inserts the string into the regionTable table.

The addRegion stored procedure is defined like this:

CREATE PROCEDURE addRegion (IN region VARCHAR(64),
                            OUT region_count INTEGER)
BEGIN
   INSERT INTO regionTable VALUES (:region);
   SEL COUNT(*) INTO :region_count FROM regionTable;
END;

The regionTable table is defined like this:

CREATE TABLE regionTable (region VARCHAR(64));