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

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

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.