Cursors > Results Retrieval > Binding to User-Allocated Memory
 
Binding to User-Allocated Memory
An interesting optimization consists of retrieving the data directly into your application memory space. To achieve this, use one of the overloaded member functions IldRequest::bindCol. The first one uses the column index in the result set as a key, whereas the second one uses the column name.
If you choose this method, be aware that when Rogue Wave DB Link compares the strings, the comparison is case-sensitive. Some RDBMSs use only uppercase while others use lowercase letters, or are case-sensitive themselves.
To find out how your target RDBMS handles character cases, you can call the function IldDbms::getInfo for information item IldIdentifierCase.
Here is an example:
{
// 1/ parse a selection request
const char* selectStr = "select NAME, AGE from BINDTABLE";
cout << "Parsing select request: " << selectStr << endl;
if (!request->parse(selectStr)) {
IldDisplayError("Parse failed: ", request);
delete cust;
Ending(dbms, request);
}
cout << endl;
// 2/ declare binding of outputs
cout << "Binding output: " << endl;
cout << " column NAME bound to customer name slot" << endl;
if (!request->bindCol((IlUShort)0, IldStringType,
cust->name, 20)) {
IldDisplayError("Column binding failed:", request);
delete cust;
Ending(dbms, request);
}
cout << " column AGE bound to customer age slot" << endl;
if (!request->bindCol(1, IldIntegerType, &(cust->age))) {
IldDisplayError("Column binding failed:", request);
delete cust;
Ending(dbms, request);
}
cout << endl;
// 3/ execute the select request
cout << "Executing the select request" << endl;
if (!request->execute()) {
IldDisplayError("Execution failed: ", request);
delete cust;
Ending(dbms, request);
}
}

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