Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-3CCA6503-54DA-5558-85DC-93A22A81F565" xml:lang="en"><title>Reading
to Memory</title><shortdesc>This tutorial describes how to copy data from the table to a memory
location.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-55DBC83C-C1C8-4730-B579-B583B3E509A0"><title>Introduction</title> <p>You can avoid making a local copy
of the data by directly writing the retrieved data into a memory location.
This can be achieved by copying to an object of the <xref href="GUID-5CD07A27-E3ED-3273-A560-680501468C91.dita"><apiname>TPtrC</apiname></xref> class.
For more details on copying data to a buffer see <xref href="GUID-72511204-FC90-54AA-9E2E-833318020318.dita">Reading
to a Buffer</xref>. </p> </section>
<section id="GUID-D705EE04-5FBB-4295-B4E2-EEBA51E9AD66"><title>Basic procedure</title> <p>The high level steps to copy the
data retrieved from a table to a memory location are shown below: </p> <ol id="GUID-E2B78DD5-841E-526B-A6BE-C8ACCF79FA6D">
<li id="GUID-7F20C95F-0225-58A9-92EE-86DF83AD9C2B"><p>Configure your SQL statement. </p> </li>
<li id="GUID-F4A653E4-571E-52D0-960E-98B995666B75"><p>Copy to memory. </p> </li>
</ol> </section>
<section id="GUID-48CD7D85-5E02-4EB2-B899-60B57D81260A"><title>Detailed steps</title> <p><b>Configure your SQL statement</b> </p> <p>Instantiate
an object of the <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> class and declare the required
variables as shown. </p> <codeblock id="GUID-188E5840-729F-5F63-9498-086B8EE5C6D3" xml:space="preserve">RSqlStatement myStatement;
TInt err;</codeblock> <p><b>Copy to memory</b> </p><p>To retrieve all the
entries, use a loop. </p><p/><p>1. Instantiate an object
of the <xref href="GUID-E884CBEB-A5B5-308E-8E88-9A1543184899.dita"><apiname>TPtrc</apiname></xref> class. This object may be used to reference
constant strings or data. </p><codeblock xml:space="preserve">...
while((err = myStatement.Next()) == KSqlAtRow)
{
TPtrC myData;
TInt err;
</codeblock><p>2 Read the data into the specified memory location..</p><codeblock xml:space="preserve"> err = myStatement.ColumnBinary(myColumnIndex,myData);
// process data
}</codeblock> </section>
<section id="GUID-46884F2A-208C-4EA9-BE1D-2D50D30FFE99"><title>See also</title> <p><xref href="GUID-C60DAE3D-7FB9-5619-9E5D-476A430705AF.dita">Querying
a Database</xref> </p> <p> <xref href="GUID-CCB9C61B-FB28-5CD9-A366-4A9584097897.dita">Inserting
a Row into a Table</xref> </p> <p><xref href="GUID-B61EA8C5-0966-51DE-AC73-01DD34C7D3CC.dita">Deleting
Rows from a Table</xref> </p> <p> <xref href="GUID-72511204-FC90-54AA-9E2E-833318020318.dita">Reading
to a Buffer</xref> </p> <p>Reading to memory - This document </p> <p> <xref href="GUID-183280EE-0C57-54FE-8ABB-E1CC3BDE525B.dita">Reading to a Data Stream</xref> </p> <p> <xref href="GUID-B9A3B17E-BDEB-5F66-968C-080335A721AC.dita">Writing to a Data Stream</xref> </p> <p> <xref href="GUID-C474376E-1766-5781-B5BF-3786C5B4D72E.dita">Performing Scalar Queries</xref> </p> </section>
</conbody></concept>