diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/PDK/Source/GUID-72511204-FC90-54AA-9E2E-833318020318.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/PDK/Source/GUID-72511204-FC90-54AA-9E2E-833318020318.dita Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,18 @@ + + + + + +Reading to a Buffer

This tutorial describes how to read the data from the table into a buffer.

Introduction

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.

Basic procedure

The high level steps to read the data into the buffer are shown here:

  1. Configure the SQL statement.

  2. Allocate memory and copy data.

  3. Deallocate memory.

Detailed steps

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:

  1. Instantiate an object of the RBuf class.

    while((err = myStatement.Next()) == KSqlAtRow) + { + RBuf myBuffer;
  2. Allocate enough memory to hold the column data using the CreateL() function as shown below.

    err = myBuffer.CreateL(myStatement.ColumnSize(columnIndex));
  3. Copy the data from the table into the buffer using ColumnBinary() function.

    err = myStatement.ColumnBinary(myColumnIndex,myBuffer); + ... + // process data

Deallocate memory

Deallocate the memory assigned to the RBuf object.

myBuffer.Close(); + }
See also

Querying a Database

Deleting Rows from a Table

Reading to a buffer - This document

Reading to Memory

Reading to a Data Stream

Writing to a Data Stream

Performing Scalar Queries

\ No newline at end of file