16.20 - Phases of a Variable Mode Table Function - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL External Routine Programming

Advanced SQL Engine
Teradata Database
Release Number
Release Date
April 2020
Content Type
Programming Reference
Publication ID
English (United States)

Teradata Database invokes a variable mode table function repeatedly, allowing the function to pass through different phases where it initializes itself, connects to external objects, builds output rows, closes open connections, and cleans up. The function can use the FNC_GetPhase or the FNC_GetPhaseEx library function to determine which phase it is in and what action to take.

A function that uses the FNC_GetPhase library function passes through the following phases.

FNC_GetPhase library function phases

Alternatively, a table function that needs to know when it is passed in the last qualified row on an AMP (perhaps because the function does not return a row until it has processed all of the input rows) can use the FNC_GetPhaseEx function with the TBL_LASTROW option and pass through the following phases.

FNC_GetPhaseEx library function phases

For more information on implementing each phase of a variable mode table function, see Implementation Guidelines.