16.20 - Overall Procedure - 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)

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.

    -OR-

    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.