This tutorial describes how to read the data from the table into a buffer.
This query allows you to retrieve the data in a field. You can retrieve one entry or multiple entries in the same column by executing the query in a loop.
The steps to read data to a buffer are as follows:
Configure the SQL statement
Instantiate an RSqlStatement object and declare the variables as required.
RSqlStatement myStatement; TInt err;
Allocate memory and copy data
To retrieve all the entries, use a loop. The steps to be performed within the loop are as described below:
Instantiate an object of the RBuf class.
while((err = myStatement.Next()) == KSqlAtRow) { RBuf myBuffer;
Allocate enough memory to hold the column data using the CreateL() function as shown below.
err = myBuffer.CreateL(myStatement.ColumnSize(columnIndex));
Copy the data from the table into the buffer using RSqlStatement::ColumnBinary(TInt,TDes8 &)const function.
err = myStatement.ColumnBinary(myColumnIndex,myBuffer); ... // process data
Deallocate memory
Deallocate the memory assigned to the RBuf object.
myBuffer.Close(); }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.