16.20 - tdr.SetAttributeByNdx - 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)

Purpose

Sets the value of an individual attribute in the current output stream row.

Syntax

tdr.SetAttributeByNdx(  handle,  index,  attribute, coldef)
handle
Parameter type: raw vector

The handle of the output stream returned by the tdr.Open function.

index
Parameter type: integer

The index of an attribute. The valid range is from 0 to n-1, where n is the number of attributes in the stream. Index 0 indicates the first attribute.

attribute
Parameter type: list

The attribute value to be set in the form of a list containing the value and a null indicator. This is the return value of a call to the tdr.GetAttributeByNdx function.

coldef
Parameter type: list

The schema of a stream. This schema is a list with the number of columns and the definition of each column. Each definition includes the column information for the data type of that specific column. This is the return value of a call to the tdr.GetColDef function.

If coldef is NULL, the function will retrieve the coldef information.

Usage Notes

The coldef parameter can be used to improve performance. By passing the coldef information to the function, the function does not have to retrieve it on each call. However, you can optionally pass NULL instead and the function will retrieve the coldef information by itself.

Before you call this function, you must call the tdr.Open function to open the output stream. Then pass the handle returned from tdr.Open as an argument to this function.

This function is valid only if called from the table operator.
The function raises an error in the following situations:
  • The handle is associated with an input stream.
  • The output stream is not open.
  • The index is not valid.
  • The coldef list contains an invalid data type or an incomplete set of attributes for that data type.
  • The attribute is not of type list.
  • The type of the input attribute is different from the type of attribute at the given index.
  • This function was called from the contract function.

Example: Set the First Attribute in the Current Row of the Output Stream

This example sets the first attribute in the current row of the output stream to value 123.

myatt <- list ( value=as.integer(123), nullIndicator=0 );
tdr.SetAttributeByNdx(outHandle, 0, myatt, NULL);

In the previous example, NULL was passed as the coldef parameter; therefore, the function retrieves the coldef information.

In the following example, the coldef information is passed to the function. This would improve performance.

myatt <- list ( value=as.integer(123),nullIndicator=0);
coldef <- tdr.GetColDef(streamno, direction);
tdr.SetAttributeByNdx(outHandle, 0, myatt, coldef);