16.20 - tdr.GetColDef - 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

Retrieves the schema of the input or output stream.

Syntax

tdr.GetColDef(  streamno,  direction  )
streamno
Parameter type: integer

The stream number.

direction
Parameter type: character
Valid values are as follows:
  • "R" (input)
  • "W" (output)

Return Value

A list with the schema of the specified stream. This list includes the definition of each column, including the following information:
  • Name
  • Type

    Valid data type values are defined by the dtype_en enumeration in the sqltypes_td.h header file.

  • Size (in bytes)
  • Character type for textual fields:
    • 1 for LATIN
    • 2 for UNICODE

Example: Get the Column Definitions of an Input Stream

stream <- 0;
direction <- "R";
incols <- tdr.GetColDef(stream, direction);
print(incols);

The list incols contains the following for a stream with three attributes (COL1 int, COL2 real, COL3 varchar(30)):

$COL1
$COL1$datatype
[1] 9

$COL1$bytesize
[1] 4

$COL2
$COL2$datatype
[1] 10

$COL2$bytesize
[1] 8

$COL3
$COL3$datatype
[1] 2

$COL3$charset
[1] 1

$COL3$size.length
[1] 30
You can get the number of columns in the stream by calling the length function:
length(incols)