FNC_SetXMLClob Function | C Library Functions | Teradata Vantage - FNC_TblAbort - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
lifecycle
latest
Product Category
Teradata Vantageā„¢

Allows a table function or a table operator to gracefully stop a request when an error condition prevents continuation.

If this copy of the table function stops the request, FNC_TblAbort returns 1.

If another copy of the table function stops the request, FNC_TblAbort returns 0.

This library function is valid during any phase or mode in which the table function was invoked.

Syntax

int
FNC_TblAbort(void)

Usage Notes

Because any copy of the table function can call FNC_TblAbort, the table function must check the return value to determine which copy made the call.

Return Value Meaning
0 Another copy of the table function initiated the stop.

Upon return of the call to FNC_TblAbort, this copy of the table function returns.

This copy of the function is called again, and when the function calls FNC_GetPhase, the FNC_Phase argument is set to TBL_ABORT. The function can close all resources and release any allocated memory.

1 This copy of the table function initiated the stop.

The other copies of the table function are notified of the stop the next time they call FNC_GetPhase, when the the value of the FNC_Phase return argument is TBL_ABORT.

Control returns to this copy of the table function after all other copies return from the TBL_ABORT phase, when the table function takes the following steps:
  1. Set the sqlstate argument to an appropriate SQLSTATE exception condition.

    For more information, see Returning SQLSTATE Values.

  2. Set the error_message string to the error message text. The characters must be inside the LATIN character range.
  3. Close all resources and release any allocated memory.
  4. Write to an external log or send external error notification messages, if applicable.
  5. Return.

This function can only be called from within a table function or a table operator. Calling this function from a UDM, external stored procedure, scalar function, or aggregate function results in an exception on the transaction.

Example Using FNC_TblAbort

FNC_Phase    Phase;

if (FNC_GetPhase(&Phase) == TBL_MODE_CONST)    {
   switch(Phase)
   {
      ...
      case TBL_BUILD:
      {
         ...
         /* Get some bad data here. Need to abort. */
         if( FNC_TblAbort() )             {
            /* At this point, all other copies of the function */
            /* should have finished cleaning up */
            strcpy(sqlstate, "U0004");
            strcpy(error_message, "Bad Input data - not processed");
         break;
      }
      ...
   }
}
...