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.
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.
For more information on implementing each phase of a variable mode table function, see Implementation Guidelines.