Overall Procedure | Debugging Using Trace Tables | Teradata Vantage - 17.10 - Overall Procedure - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL External Routine Programming

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

Here is a synopsis of the steps you take to debug scalar, aggregate, and table functions using trace tables.

You can also use this procedure to debug external stored procedures.
  1. Create a trace table using the CREATE GLOBAL TEMPORARY TRACE TABLE statement.

    The first two columns of the trace table are used by the Teradata function trace subsystem. Any columns that are defined beyond the first two are available for a UDF to use to write trace output during execution.

  2. Enable the trace table for function trace output using the SET SESSION FUNCTION TRACE statement.

    You can specify an optional function trace string that the UDF can obtain during execution.

  3. Invoke the function.
  4. Call FNC_Trace_String in the UDF to get the function trace string that was specified in the SET SESSION FUNCTION TRACE statement.

    You can use the value of the trace string to determine what to output to the trace table.

  5. Call FNC_Trace_Write_DL to write trace output to the columns of a trace table.


    If you are debugging an aggregate or table function, you can optionally call FNC_Trace_Write, which is restricted to UDFs that execute on an AMP.

  6. Use a SELECT statement to query the trace table and retrieve the trace output from the UDF.