This tutorial shows you how to create a simple SQL database query.
This tutorial shows you how to wrap a SQL query statement into an RSqlStatement object to query a database.
The SQL statement used for the tutorial is shown here:
SELECT name FROM countries WHERE population > 10
The ( SELECT ) results of the query will be the value in the ' name ' column FROM the ' countries ' table WHERE the value of the ' population ' column of the same record is > the value specified.
Prepare the Statement:
The steps to prepare a SQL statement are shown here.
Set up some constants used by the SQL statement object to define the SQL query:
This defines the query parameters.
Instantiate the RSqlStatement SQL statement:
Define the indices to be used in the search:
Set the 32-bit integer value for the SQL parameter 'value':
The SQL parameter to which the integer is being assigned is identified by the constant kVal from:
The parameter plus constant, along with other parts of the statement, are converted into:
in SQL syntax.
Prepare the statement:
This creates a parameterised SQL statement executable.
Run the SQL query:
The query is done and you have the results. In this section we look at a simple way to do something with the results and we close the SQL statement object.
This section deals with finding and returning the first matching record
only. Getting all matches in a database is briefly discussed at the end of this
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.