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

Reads a row from an input stream.

Syntax

tdr.Read(  handle  )
handle
Parameter type: raw vector

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

Return Value

An integer indicating one of the following results.

Return Code Description
0 The operation was successful.
-1 The end of stream was reached.
-2 The table operator aborted.
-3 The input parameter has an invalid type.
-4 The input parameter has an invalid value.
-5 This function was called from the contract function.

Usage Notes

Before you call this function, you must call the tdr.Open function to open the input 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.

Example: Reading Rows From the Input Stream

This example opens an input stream and counts the number of rows successfully read from the input stream.

# Open the input stream.
library(tdr);
stream <- 0;
options <- 0;
direction <- "R";
inHandle <- tdr.Open(direction, stream, options);

# Read rows from the input stream.

nrrows <- 0;
while (tdr.Read(inHandle) == 0) {
  nrrows <- nrrows+1;
}