Symbian3/SDK/Source/GUID-B61EA8C5-0966-51DE-AC73-01DD34C7D3CC.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-B61EA8C5-0966-51DE-AC73-01DD34C7D3CC" xml:lang="en"><title>Deleting
Rows from a Table</title><shortdesc>This tutorial describes how to delete rows from a database table. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-C621392D-0382-4F37-8A9E-01DD884A40C1"><title>Introduction</title> <p>The deletion of a record from a database
can be performed by executing the <codeph>DELETE</codeph> SQL statement. The
query does not pass or return any data. </p> </section>
<section id="GUID-F6B8AD97-4118-414C-9A1C-CD8C0738731A"><title>Basic procedure</title> <ul>
<li id="GUID-9C914C4E-72E0-5115-8C66-BE37C6DBD21A"><p>Configure the SQL statement </p> </li>
<li id="GUID-6CA0261D-EE6B-53B5-921C-163AB03F0D04"><p>Execute the statement. </p> </li>
</ul> </section>
<section id="GUID-A578F91F-797E-4A43-A8A4-82CD416BB471"><title>Detailed steps</title> <p><b>Configure
the SQL statement</b> </p> <p>Create a literal for your <codeph>DELETE</codeph> statement.
You do not need to create a <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> object to run
a <codeph>DELETE</codeph> statement. You need to just execute the query with
the <xref href="GUID-4688F6B7-E1B0-37CF-BAA2-C6BD103D4FDF.dita"><apiname>RSqlDatabase</apiname></xref> object, which has its own <xref href="GUID-4688F6B7-E1B0-37CF-BAA2-C6BD103D4FDF.dita#GUID-4688F6B7-E1B0-37CF-BAA2-C6BD103D4FDF/GUID-6D2120DC-C193-3E2E-A802-B4CD180BDF11"><apiname>RSqlDatabase::Exec()</apiname></xref> function
taking a query string as its parameter. </p> <codeblock id="GUID-16ECCA77-5B8D-5D64-AFF0-ED634323C1DD" xml:space="preserve">_LIT(kQueryString,"DELETE FROM countries WHERE population &lt; 2;"); 
</codeblock> <p> <b>NOTE :</b> It is possible to call a <codeph>DELETE</codeph> statement
from an <xref href="GUID-0176BF07-DF94-3259-8F90-DE030E35CE9A.dita"><apiname>RSqlStatement</apiname></xref> object, but it is computationally
more expensive and you are recommended not to do so. </p> <p><b>Execute the statement</b> </p> <p>Execute the <codeph>DELETE</codeph> statement.
This code assumes that the <codeph>countriesDatabase</codeph> object is open. </p> <codeblock id="GUID-E247DCDC-8EAA-5543-AB4C-C938CEAA51FB" xml:space="preserve">countriesDatabase.Exec(kQueryString);</codeblock> </section>
<section id="GUID-B884F66D-1000-426D-850A-49CF5966F4AD"><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>Deleting Rows from a Table - This document </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> <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>