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
To retrieve a large text value at once into memory, after having successfully executed an SQL select statement, use the function getColLongTextValue.
Warning The memory chunk internally allocated by DB Link is limited to 64 Kilobytes.
{
while (request->fetch().hasTuple())
cout << request->getColLongTextValue(0) << endl;
}
To retrieve a large binary value at once into memory, after having successfully executed an SQL select statement, use the member function getColBinaryValue.
Warning The memory chunk internally allocated by 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 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,
-
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:
-
Initiate the process by a call to the function startGetLargeObject, which issues the initial SQL select statement.
This function takes the following three arguments:
-
Iterate by calling the function 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.






