Fetch Operation
Once the binding process is complete, the cursor is ready to fetch data. Invoking the member function fetchRow() accomplishes this. Using the addresses given to the cursor in the bind stage, one row of data is retrieved from the database. The following is an example of using a cursor for fetching data:
 
RWDBTable inventory = aDatabase.table("inventory");
RWDBSelector aSelector = aDatabase.selector();
aSelector << inventory["partNumber"] << inventory["onHand"];
aSelector.orderBy(inventory["partNumber"]);
 
RWDBCursor aCursor = aDatabase.cursor(aSelector);
unsigned long partNumber;
unsigned int numberOnHand;
aCursor << &partNumber << &numberOnHand;
std::cout << "Part Number\tQuantity" << std::endl;
while (aCursor.fetchRow().isValid())
std::cout << partNumber << '\t' << numberOnHand << std::endl;