tdr.LobRead Function | R Table Operators | Teradata Vantage - tdr.LobRead - Advanced SQL Engine - Teradata Database

SQL External Routine Programming

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-24
dita:mapPath
qwr1571437338192.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1147
lifecycle
previous
Product Category
Teradata Vantage™

Purpose

Reads a LOB.

Syntax

tdr.LobRead(contextID,  length)
contextID
Parameter type: integer

The context ID returned by the tdr.LobOpen_CL function.

length
Parameter type: numeric

The number of bytes to read.

Return Value

A raw vector with the LOB content.

If the function encounters an error, NULL is returned.

Usage Notes

Before you call this function, you must call the tdr.LobOpen_CL function to get the context ID. Then pass this context ID as an argument to this function.

This function is valid only if called from the table operator.

An error is raised if the function is called from the contract function.

Example: Read a LOB

Consider an input table with 5 attributes: (int, int, int, int, clob). This example shows how to read the last attribute of the current row as follows:
  • Get the LOB locator
  • Open the LOB
  • Read the LOB
  • Close the LOB
# Open the input stream
inHandle <- tdr.Open("R", 0, 0);

# Get the 5th attribute in the current row (LOB locator)
att5 <- tdr.GetAttributeByNdx(inHandle, 4, NULL);

# Open the LOB for reading
inlob <- tdr.LobOpen_CL(att5,0,0);

# Read the LOB, convert it to character, and print it
string <- tdr.LobRead(inlob$contextID, inlob$LOBlen);
print(rawToChar(string$buffer));

# Close the LOB
tdr.LobClose(inlob$contextID);