This tutorial describes the way in which you can execute scalar queries.
A scalar query is a SELECT statement which refers to several data fields and returns a single result, for example, a COUNT query on a database column. This gives the number of records in the database. Symbian platform provides a class TSqlScalarFullSelectQuery , for making scalar queries. This is more efficient than the RSqlStatement class.
To make a scalar query, do the following:
Declare the necessary variables
Instantiate an object of the database class.
RSqlDatabase myDatabase;
Declare a literal to hold the query string
_LIT(kQueryString,"SELECT COUNT (*) FROM myTable");
Instantiate an object of the TSqlScalarFullSelectQuery class. This class has a peculiar feature of instantiating an instance of it with a parameter that refers to the database to be queried. The class supplies a number of functions taking SELECT statements as parameters.
TSqlScalarFullSelectQuery myFullSelectQuery(myDatabase);
Execute the query
Execute the query
TInt recCount = myFullSelectQuery.SelectIntL(kQueryString));
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.