Cursors > Large Objects (LOBs) > Different Ways of Retrieving Large Objects
 
Different Ways of Retrieving Large Objects
To retrieve LOBs, you can choose one of the following three methods:
*Getting the whole contents at once into memory (with some limitations);
*Getting the whole contents at once into a file;
*Getting the contents in memory chunks.
Retrieving into Memory
*Long Text Values
To retrieve a large text value at once into memory, after having successfully executed an SQL select statement, use the function IldRequest::getColLongTextValue.
Warning: The memory chunk internally allocated by Rogue Wave DB Link is limited to 64 Kilobytes.
{
while (request->fetch().hasTuple())
cout << request->getColLongTextValue(0) << endl;
}
*Long Binary Values
To retrieve a large binary value at once into memory, after having successfully executed an SQL select statement, use the member function IldRequest::getColBinaryValue.
Warning: The memory chunk internally allocated by Rogue Wave DB Link is limited to 64 Kilobytes.
Retrieving into a Named File
To retrieve a large text value at once into a named file, use the member function IldRequest::getLargeObject. The member function itself issues the initial SQL select statement. There is no program limit on the size of the data value.
This function can be used for IldLongTextType values as well as for IldBinaryType values. It takes the following four arguments:
*The table name,
*The column name,
*A reduced where clause,
*The full path name of the file where the column data is to be saved.
{
if (!request->getLargeObject("DBLTEXT", "TVAL",
"NAME = '1st Text'","/tmp/text1")) {
IldDisplayError("Text retrieval failed:", request);
Ending(dbms, request);
}
}
Retrieving in Chunks of Memory
To retrieve a large text or binary value in chunks of memory:
1. Initiate the process by a call to the function IldRequest::startGetLargeObject, which issues the initial SQL select statement.
This function takes the following three arguments:
*The table name,
*The column name,
*The reduced where clause.
2. Iterate by calling the function IldRequest::getLargeObjectChunk until the offset argument is left unchanged by the call, meaning that no more data was returned.
Since you pass the address of a preallocated memory chunk as the second argument to the call, it is up to you to decide the memory limitation.
The third argument is ignored on input for all RDBMSs except Oracle. Oracle allows you to fetch from any offset in the column value.
All other database systems only allow retrieving chunks by ascending, not by overlapping, indexes. On output, the argument is set to its entry value, increased by the total number of bytes actually read so far.
These functions can be used for IldLongTextType values as well as for IldBinaryType values.

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.