Symbian3/SDK/Source/GUID-72511204-FC90-54AA-9E2E-833318020318.dita
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
equal deleted inserted replaced
7:51a74ef9ed63 8:ae94777fff8f
    10 <!DOCTYPE concept
    10 <!DOCTYPE concept
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
    12 <concept id="GUID-72511204-FC90-54AA-9E2E-833318020318" xml:lang="en"><title>Reading
    12 <concept id="GUID-72511204-FC90-54AA-9E2E-833318020318" xml:lang="en"><title>Reading
    13 to a Buffer</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    13 to a Buffer</title><prolog><metadata><keywords/></metadata></prolog><conbody>
    14 <p>This tutorial describes how to read the data from the table into a buffer. </p>
    14 <p>This tutorial describes how to read the data from the table into a buffer. </p>
    15 <section id="GUID-2FC55195-ADCC-486A-8F48-6C199545436B"><title>Introduction</title> <p>This query allows you to retrieve
    15 <section id="GUID-2FC55195-ADCC-486A-8F48-6C199545436B"><title>Introduction</title> <p>This
    16 the data in a field. You can retrieve one entry or multiple entries in the
    16 query allows you to retrieve the data in a field. You can retrieve one entry
    17 same column by executing the query in a loop. </p> </section>
    17 or multiple entries in the same column by executing the query in a loop. </p> </section>
    18 <section id="GUID-6221B43F-E095-43A6-8779-A95FBFEBFE5F"><title>Basic procedure</title> <p>The high level steps to read the
    18 <section id="GUID-6221B43F-E095-43A6-8779-A95FBFEBFE5F"><title>Basic procedure</title> <p>The
    19 data into the buffer are shown here: </p> <ol id="GUID-3E8A8F9B-DFC3-5809-93FF-899287668CC3">
    19 high level steps to read the data into the buffer are shown here: </p> <ol id="GUID-3E8A8F9B-DFC3-5809-93FF-899287668CC3">
    20 <li id="GUID-E42FA395-D5D4-5CE5-B6C2-4F81049D1973"><p>Configure the SQL statement. </p> </li>
    20 <li id="GUID-E42FA395-D5D4-5CE5-B6C2-4F81049D1973"><p>Configure the SQL statement. </p> </li>
    21 <li id="GUID-5C982F27-27E8-5AA1-A555-B7C54D3EB92F"><p>Allocate memory and
    21 <li id="GUID-5C982F27-27E8-5AA1-A555-B7C54D3EB92F"><p>Allocate memory and
    22 copy data. </p> </li>
    22 copy data. </p> </li>
    23 <li id="GUID-CC3E796C-4637-50BF-BA10-559F72E9AD2D"><p>Deallocate memory. </p> </li>
    23 <li id="GUID-CC3E796C-4637-50BF-BA10-559F72E9AD2D"><p>Deallocate memory. </p> </li>
    24 </ol> </section>
    24 </ol> </section>
    25 <section id="GUID-B53573AE-EEF9-4477-8088-12059025054A"><title>Detailed steps</title> <p>The steps to read data to a buffer
    25 <section id="GUID-B53573AE-EEF9-4477-8088-12059025054A"><title>Detailed steps</title> <p>The
    26 are as follows: </p> <p><b>Configure
    26 steps to read data to a buffer are as follows: </p> <p><b>Configure
    27 the SQL statement</b> </p> <p>Instantiate an <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> object
    27 the SQL statement</b> </p> <p>Instantiate an <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> object
    28 and declare the variables as required. </p> <codeblock id="GUID-1948DBCA-AA3A-5856-B749-16A8A26FF4BC" xml:space="preserve">RSqlStatement myStatement;
    28 and declare the variables as required. </p> <codeblock id="GUID-1948DBCA-AA3A-5856-B749-16A8A26FF4BC" xml:space="preserve">RSqlStatement myStatement;
    29 TInt err;</codeblock> <p><b>Allocate
    29 TInt err;</codeblock> <p><b>Allocate
    30 memory and copy data</b> </p> <p>To retrieve all the entries, use a loop.
    30 memory and copy data</b> </p> <p>To retrieve all the entries, use a loop.
    31 The steps to be performed within the loop are as described below: </p> <ol id="GUID-350EBCA3-166E-5B94-BACF-9A3FDF0B0E1D">
    31 The steps to be performed within the loop are as described below: </p> <ol id="GUID-350EBCA3-166E-5B94-BACF-9A3FDF0B0E1D">
    32 <li id="GUID-F7E93B5F-793C-53C5-B97C-206589FC33AA"><p>Instantiate an object
    32 <li id="GUID-F7E93B5F-793C-53C5-B97C-206589FC33AA"><p>Instantiate an object
    33 of the <xref href="GUID-BFBC574B-EFF6-37A4-9189-B71DA1505BC8.dita"><apiname>RBuf</apiname></xref> class. </p> <codeblock id="GUID-E2DB2F48-B1D6-5496-BF41-108E39F1C938" xml:space="preserve">while((err = myStatement.Next()) == KSqlAtRow)
    33 of the <codeph>RBuf</codeph> class. </p> <codeblock id="GUID-E2DB2F48-B1D6-5496-BF41-108E39F1C938" xml:space="preserve">while((err = myStatement.Next()) == KSqlAtRow)
    34     {
    34     {
    35     RBuf myBuffer;</codeblock> </li>
    35     RBuf myBuffer;</codeblock> </li>
    36 <li id="GUID-3E3552E9-42F2-5715-B5CB-1D0412B62D09"><p>Allocate enough memory
    36 <li id="GUID-3E3552E9-42F2-5715-B5CB-1D0412B62D09"><p>Allocate enough memory
    37 to hold the column data using the <codeph>CreateL()</codeph> function as shown
    37 to hold the column data using the <codeph>CreateL()</codeph> function as shown
    38 below. </p> <codeblock id="GUID-FD2C9AB5-BD1E-5FFF-A77F-27DD437663DA" xml:space="preserve">err = myBuffer.CreateL(myStatement.ColumnSize(columnIndex));</codeblock> </li>
    38 below. </p> <codeblock id="GUID-FD2C9AB5-BD1E-5FFF-A77F-27DD437663DA" xml:space="preserve">err = myBuffer.CreateL(myStatement.ColumnSize(columnIndex));</codeblock> </li>
    39 <li id="GUID-8E9C1C93-B5B2-5963-B418-FF16C1B873E7"><p>Copy the data from the
    39 <li id="GUID-8E9C1C93-B5B2-5963-B418-FF16C1B873E7"><p>Copy the data from the
    40 table into the buffer using <xref href="GUID-58179FB4-4D5B-3FC4-BF51-1221D8EE4D71.dita"><apiname>ColumnBinary()</apiname></xref> function. </p> <codeblock id="GUID-B0EDB685-F549-5B67-ACFE-DEEF636E0066" xml:space="preserve">    err = myStatement.ColumnBinary(myColumnIndex,myBuffer);
    40 table into the buffer using <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita#GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A/GUID-91BB3C7E-8B2C-363B-AB9A-E27769D12409"><apiname>RSqlStatement::ColumnBinary(TInt,TDes8
       
    41 &amp;)const</apiname></xref> function. </p> <codeblock id="GUID-B0EDB685-F549-5B67-ACFE-DEEF636E0066" xml:space="preserve">    err = myStatement.ColumnBinary(myColumnIndex,myBuffer);
    41     ...
    42     ...
    42     // process data</codeblock> </li>
    43     // process data</codeblock> </li>
    43 </ol> <p><b>Deallocate
    44 </ol> <p><b>Deallocate
    44 memory</b> </p> <p>Deallocate the memory assigned to the <codeph>RBuf</codeph> object. </p> <codeblock id="GUID-6C46064D-7B65-520E-B378-0BD689D4FD8F" xml:space="preserve">myBuffer.Close();
    45 memory</b> </p> <p>Deallocate the memory assigned to the <codeph>RBuf</codeph> object. </p> <codeblock id="GUID-6C46064D-7B65-520E-B378-0BD689D4FD8F" xml:space="preserve">myBuffer.Close();
    45     }</codeblock> </section>
    46     }</codeblock> </section>
    46 <section id="GUID-F0F18DB6-7D49-4515-8419-11830C5B22F7"><title>See also</title> <p><xref href="GUID-C60DAE3D-7FB9-5619-9E5D-476A430705AF.dita">Querying
    47 <section id="GUID-F0F18DB6-7D49-4515-8419-11830C5B22F7"><title>See also</title> <p><xref href="GUID-C60DAE3D-7FB9-5619-9E5D-476A430705AF.dita">Querying a Database</xref>  </p> <p> <xref href="GUID-B61EA8C5-0966-51DE-AC73-01DD34C7D3CC.dita">Deleting Rows from a Table</xref>  </p> <p>Reading
    47 a Database</xref>  </p> <p> <xref href="GUID-B61EA8C5-0966-51DE-AC73-01DD34C7D3CC.dita">Deleting
    48 to a buffer - This document </p> <p> <xref href="GUID-3CCA6503-54DA-5558-85DC-93A22A81F565.dita">Reading
    48 Rows from a Table</xref>  </p> <p>Reading to a buffer - This document </p> <p> <xref href="GUID-3CCA6503-54DA-5558-85DC-93A22A81F565.dita">Reading to Memory</xref>  </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>
    49 to Memory</xref>  </p> <p> <xref href="GUID-183280EE-0C57-54FE-8ABB-E1CC3BDE525B.dita">Reading
       
    50 to a Data Stream</xref>  </p> <p> <xref href="GUID-B9A3B17E-BDEB-5F66-968C-080335A721AC.dita">Writing
       
    51 to a Data Stream</xref>  </p> <p> <xref href="GUID-C474376E-1766-5781-B5BF-3786C5B4D72E.dita">Performing
       
    52 Scalar Queries</xref>  </p> </section>
    49 </conbody></concept>
    53 </conbody></concept>