Provides backward compatibility for UDFs that were developed using older database releases to write trace output into a temporary trace table.
To write trace output into a temporary trace table from an external routine, use FNC_Trace_Write_DL instead.
Syntax
void FNC_Trace_Write ( int argc, void *argv[] )
Syntax Elements
- argc
- the count of output arguments in the argv array.
This value should match the number of columns in the trace table beyond the first two mandatory columns that are used by the Teradata function trace subsystem.
- argv
- an array of pointers to data to write to the columns in a temporary trace table.
Usage Notes
Trace output values are not validated. For example, stored values are incorrect when numeric values are too big for the receiving column or when character strings contain characters that are not valid.
If you store incorrect values, you might not be able to select data from the trace table. For example, if you write an invalid date to a TIMESTAMP column, a subsequent select on that data returns an invalid date error and no result. To read the bad TIMESTAMP data from the trace table and determine what is wrong, take the following steps:
- Write another UDF that defines its input argument as a TIMESTAMP and converts it to a string result.
- Use that UDF in the SELECT statement to read the TIMESTAMP data from the trace table to see what is wrong with it.
To avoid storing incorrect values that you might not be able to select, create the trace table with only character columns (beyond the first two mandatory columns) and format the output data using sprintf. For an example, see Example: Debugging a UDF Using a Trace Table.
If an output string is too long for a corresponding character column, it is truncated without generating an error.
If no SET SESSION FUNCTION TRACE statement has been submitted to enable a trace table for trace output, an FNC_Trace_Write call is ignored.
FNC_Trace_Write can only be called from a UDF that always runs on an AMP.
Example Using FNC_Trace_Write
INTEGER Sum_x;
INTEGER Sum_y;
void *argv[3];
...
Sum_x = *In_data_x;
Sum_y = *In_data_y;
argv[0] = &Sum_x;
argv[1] = &Sum_y;
argv[2] = "The input values";
FNC_Trace_Write(3, argv);
Related Information
For more information on CREATE GLOBAL TEMPORARY TRACE TABLE, see Teradata Vantageā¢ - SQL Data Definition Language Syntax and Examples, B035-1144.