Symbian3/SDK/Source/GUID-3CCA6503-54DA-5558-85DC-93A22A81F565.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?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><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>This tutorial describes how to copy data from the table to a memory location. </p>
<section><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><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><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><title>See also</title> <p> <xref href="GUID-F36E5978-29FC-57E8-8A45-2003E7767193.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-3ACF6C11-A9CC-517C-8C7D-578F41F3DDF7.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>