When you create a trace table with a CREATE GLOBAL TEMPORARY TRACE TABLE statement, you define columns that a UDF can use to write trace output during execution.
To write trace output to the trace table columns, call FNC_Trace_Write_DL in the UDF. The call takes three arguments:
- An array of pointers to data to store in the trace table columns
- A count of the array elements
- An array of the length of each array element
Consider the following trace table definition:
CREATE GLOBAL TEMPORARY TRACE TABLE UDF_Trace (vproc_ID BYTE(2) ,Sequence INTEGER ,UDF_name CHAR(15) ,x_value INTEGER) ON COMMIT DELETE ROWS;
The Teradata function trace subsystem writes values to the first two columns in the trace table.
Column | Contents |
---|---|
1 | PE or AMP vproc number on which the UDF is running |
2 | If FNC_Trace_Write_DL is called from …
|
The following statements in a UDF output values to the UDF_name and x_value columns of the trace table:
INTEGER x_value; void *column_list[2]; int length[2]; column_list[0] = sfncname; /* UDF input argument */ column_list[1] = &x_value; length[0] = strlen((const char *)sfncname); length[1] = sizeof(INTEGER); x_value = 45; FNC_Trace_Write_DL(2, column_list, length);