7 Nokia Corporation - initial contribution. |
7 Nokia Corporation - initial contribution. |
8 Contributors: |
8 Contributors: |
9 --> |
9 --> |
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 xml:lang="en" id="GUID-B9A3B17E-BDEB-5F66-968C-080335A721AC"><title>Writing from a Data Stream</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This tutorial describes how to write data from a data stream to a database. </p> <section><title>Introduction</title> <p>This is useful when populating your database with the results of some other operation. </p> </section> <section><title>Basic procedure</title> <p>The high level steps to write from a data stream to a database table are shown here: </p> <ol id="GUID-FDE9AAB3-C033-5700-B173-75F229BFA230"><li id="GUID-117F41A0-B71D-5327-A053-F9C458636D48"><p>Instantiate the necessary objects. </p> </li> <li id="GUID-6999251A-C025-5F3C-AEEF-B9FBED0C5AF5"><p>Write data into the table. </p> </li> <li id="GUID-4E8B4501-9EAF-5B31-8C6D-6D28BAB82445"><p>Commit the stream. </p> </li> </ol> </section> <section><title>Writing from a data stream into a table</title> <p>The process of writing data from a data stream into a table can be explained as follows: </p> <p><b> Instantiate the necessary objects</b> </p> <ol id="GUID-9EDAB491-57F6-59E9-A7FA-ADB5F1E7E8F7"><li id="GUID-C21DE9E5-6A8D-5B18-9D95-D978BC1ABF20"><p>Instantiate an object of the <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> and <xref href="GUID-6313887C-8DE0-3702-BF4B-0622BAB2EE8E.dita"><apiname>RSqlParamWriteStream</apiname></xref> class. Also declare the variables as shown. </p> <codeblock id="GUID-83A9423B-4CC6-5965-B25A-01748EFA85C8" xml:space="preserve">RSqlStatement myStatement; |
12 <concept id="GUID-B9A3B17E-BDEB-5F66-968C-080335A721AC" xml:lang="en"><title>Writing |
|
13 from a Data Stream</title><shortdesc>This tutorial describes how to write data from a data stream to |
|
14 a database. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
15 <section id="GUID-76439F61-1909-4A9A-8CC9-B47E4424025C"><title>Introduction</title> <p>This is useful when populating your |
|
16 database with the results of some other operation. </p> </section> |
|
17 <section id="GUID-91278D72-532F-4F5D-8601-7FDB848E1D27"><title>Basic procedure</title> <p>The high level steps to write from |
|
18 a data stream to a database table are shown here: </p> <ol id="GUID-FDE9AAB3-C033-5700-B173-75F229BFA230"> |
|
19 <li id="GUID-117F41A0-B71D-5327-A053-F9C458636D48"><p>Instantiate the necessary |
|
20 objects. </p> </li> |
|
21 <li id="GUID-6999251A-C025-5F3C-AEEF-B9FBED0C5AF5"><p>Write data into the |
|
22 table. </p> </li> |
|
23 <li id="GUID-4E8B4501-9EAF-5B31-8C6D-6D28BAB82445"><p>Commit the stream. </p> </li> |
|
24 </ol> </section> |
|
25 <section id="GUID-DF93842E-37AF-4A3F-A252-39E3EA905922"><title>Writing from a data stream into a table</title> <p>The process |
|
26 of writing data from a data stream into a table can be explained as follows: </p> <p><b> Instantiate the necessary objects</b> </p> <ol id="GUID-9EDAB491-57F6-59E9-A7FA-ADB5F1E7E8F7"> |
|
27 <li id="GUID-C21DE9E5-6A8D-5B18-9D95-D978BC1ABF20"><p>Instantiate an object |
|
28 of the <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> and <xref href="GUID-6313887C-8DE0-3702-BF4B-0622BAB2EE8E.dita"><apiname>RSqlParamWriteStream</apiname></xref> class. |
|
29 Also declare the variables as shown. </p> <codeblock id="GUID-83A9423B-4CC6-5965-B25A-01748EFA85C8" xml:space="preserve">RSqlStatement myStatement; |
13 TInt err; |
30 TInt err; |
14 TInt myParameterIndex; |
31 TInt myParameterIndex; |
15 RSqlParamWriteStream myStream; |
32 RSqlParamWriteStream myStream; |
16 RBuf buf; |
33 RBuf buf; |
17 </codeblock> </li> <li id="GUID-5C911C98-E0DB-5DE8-9FDB-A154F6C4746E"><p>Clean up the stack. </p> <codeblock id="GUID-F5445748-B8A6-50F5-9066-ECFC2CC8A866" xml:space="preserve">CleanupClosePushL(myStream);</codeblock> </li> </ol> <p><b> Write data into the table</b> </p> <ol id="GUID-0AA1F57B-13A2-5E13-8D42-7B0A4FE6F36B"><li id="GUID-38F8CC09-123A-59B5-B51B-01AD770A4F19"><p>Obtain access to the data as a stream of characters. </p> <codeblock id="GUID-61291241-3C46-5624-A355-FA370B3142D0" xml:space="preserve">User::LeaveIfErrormyStream.BindTextL(myStatement,myParameterIndex));</codeblock> </li> <li id="GUID-C5D72E6D-935B-5708-B05F-24F1C3B3FFE1"><p>Write the buffer. </p> <codeblock id="GUID-92F8A3E8-D0F6-5065-9983-64453465BF18" xml:space="preserve">myStream.WriteL(buf);</codeblock> </li> </ol> <p><b> Commit the stream</b> </p> <p>Commit the stream. This ensures that the streamed data is written into the table and cannot be rolled back. </p> <codeblock id="GUID-426B03C1-A1DE-5D03-92B5-C79C3BD0ADA9" xml:space="preserve">myStream.CommitL();</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> <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>Writing from a Data Stream - This document </p> <p> <xref href="GUID-C474376E-1766-5781-B5BF-3786C5B4D72E.dita">Performing Scalar Queries</xref> </p> </section> </conbody></concept> |
34 </codeblock> </li> |
|
35 <li id="GUID-5C911C98-E0DB-5DE8-9FDB-A154F6C4746E"><p>Clean up the stack. </p> <codeblock id="GUID-F5445748-B8A6-50F5-9066-ECFC2CC8A866" xml:space="preserve">CleanupClosePushL(myStream);</codeblock> </li> |
|
36 </ol> <p><b> Write |
|
37 data into the table</b> </p> <ol id="GUID-0AA1F57B-13A2-5E13-8D42-7B0A4FE6F36B"> |
|
38 <li id="GUID-38F8CC09-123A-59B5-B51B-01AD770A4F19"><p>Obtain access to the |
|
39 data as a stream of characters. </p> <codeblock id="GUID-61291241-3C46-5624-A355-FA370B3142D0" xml:space="preserve">User::LeaveIfErrormyStream.BindTextL(myStatement,myParameterIndex));</codeblock> </li> |
|
40 <li id="GUID-C5D72E6D-935B-5708-B05F-24F1C3B3FFE1"><p>Write the buffer. </p> <codeblock id="GUID-92F8A3E8-D0F6-5065-9983-64453465BF18" xml:space="preserve">myStream.WriteL(buf);</codeblock> </li> |
|
41 </ol> <p><b> Commit |
|
42 the stream</b> </p> <p>Commit the stream. This ensures that the streamed data |
|
43 is written into the table and cannot be rolled back. </p> <codeblock id="GUID-426B03C1-A1DE-5D03-92B5-C79C3BD0ADA9" xml:space="preserve">myStream.CommitL();</codeblock> </section> |
|
44 <section id="GUID-AEF1E047-3F45-4707-9A2A-1F0F4D6EB632"><title>See also</title> <p> <xref href="GUID-C60DAE3D-7FB9-5619-9E5D-476A430705AF.dita">Querying |
|
45 a Database</xref> </p> <p> <xref href="GUID-CCB9C61B-FB28-5CD9-A366-4A9584097897.dita">Inserting |
|
46 a Row into a Table</xref> </p> <p><xref href="GUID-B61EA8C5-0966-51DE-AC73-01DD34C7D3CC.dita">Deleting |
|
47 Rows from a Table</xref> </p> <p> <xref href="GUID-72511204-FC90-54AA-9E2E-833318020318.dita">Reading |
|
48 to a Buffer</xref> </p> <p> <xref href="GUID-3CCA6503-54DA-5558-85DC-93A22A81F565.dita"> Reading |
|
49 to Memory </xref> </p> <p> <xref href="GUID-183280EE-0C57-54FE-8ABB-E1CC3BDE525B.dita">Reading |
|
50 to a Data Stream</xref> </p> <p>Writing from a Data Stream - This document </p> <p> <xref href="GUID-C474376E-1766-5781-B5BF-3786C5B4D72E.dita">Performing Scalar Queries</xref> </p> </section> |
|
51 </conbody></concept> |