TSqlScalarFullSelectQuery Class Reference
class TSqlScalarFullSelectQuery
|
TSqlScalarFullSelectQuery
interface is used for executing SELECT sql queries, which return a single row consisting of a single column value.
Examples.
CASE 1 - retrieving records count of a table:
RSqlDatabase db;
//initialize db object....
.......
TSqlScalarFullSelectQuery fullSelectQuery(db);
TInt recCnt = fullSelectQuery.SelectIntL(_L("SELECT COUNT(*) FROM PersonTbl"));
CASE 2 - retrieving specific column value using a condition in the SELECT statement:
RSqlDatabase db;
//initialize db object....
.......
TSqlScalarFullSelectQuery fullSelectQuery(db);
TInt personId = fullSelectQuery.SelectIntL(_L("SELECT ID FROM PersonTbl WHERE Name = 'John'"));
CASE 3 - retrieving a text column value, the receiving buffer is not big enough:
RSqlDatabase db;
//initialize db object....
.......
TSqlScalarFullSelectQuery fullSelectQuery(db);
HBufC* buf = HBufC::NewLC(20);
TPtr name = buf->Des();
TInt rc = fullSelectQuery.SelectTextL(_L("SELECT Name FROM PersonTbl WHERE Id = 1"), name);
TEST(rc >= 0); //the function may return only non-negative values
if(rc > 0)
{
buf = buf->ReAllocL(rc);
CleanupStack::Pop();
CleanupStack::PushL(buf);
name.Set(buf->Des());
rc = fullSelectQuery.SelectTextL(_L("SELECT Name FROM PersonTbl WHERE Id = 1"), name);
TEST(rc == 0);
}
CleanupStack::PopAndDestroy();//buf
RSqlDatabase
Constructor & Destructor Documentation
TSqlScalarFullSelectQuery()
IMPORT_C
|
TSqlScalarFullSelectQuery
|
(
|
)
|
|
TSqlScalarFullSelectQuery(RSqlDatabase &)
IMPORT_C
|
TSqlScalarFullSelectQuery
|
(
|
RSqlDatabase
&
|
aDatabase
|
)
|
|
Member Functions Documentation
SelectBinaryL(const TDesC &, TDes8 &)
SelectBinaryL(const TDesC8 &, TDes8 &)
SelectIntL(const TDesC &)
IMPORT_C
TInt
|
SelectIntL
|
(
|
const
TDesC
&
|
aSqlStmt
|
)
|
|
Executes a SELECT query which is expected to return a single row consisting of a single 32-bit integer value and returns that value.
-
leave
-
KErrNotFound, If there is no record, The function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
Parameters
const
TDesC
& aSqlStmt
|
16-bit SELECT sql query
|
SelectIntL(const TDesC8 &)
IMPORT_C
TInt
|
SelectIntL
|
(
|
const
TDesC8
&
|
aSqlStmt
|
)
|
|
Executes a SELECT query which is expected to return a single row consisting of a single 32-bit integer value and returns that value.
-
leave
-
KErrNotFound, If there is no record, The function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
Parameters
const
TDesC8
& aSqlStmt
|
8-bit SELECT sql query
|
SelectRealL(const TDesC &)
IMPORT_C
TReal
|
SelectRealL
|
(
|
const
TDesC
&
|
aSqlStmt
|
)
|
|
Executes a SELECT query which is expected to return a single row consisting of a single real value and returns that value.
-
leave
-
KErrNotFound, If there is no record, The function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
Parameters
const
TDesC
& aSqlStmt
|
16-bit SELECT sql query
|
SelectRealL(const TDesC8 &)
Executes a SELECT query which is expected to return a single row consisting of a single real value and returns that value.
-
leave
-
KErrNotFound, If there is no record, The function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
Parameters
const
TDesC8
& aSqlStmt
|
8-bit SELECT sql query
|
SelectTextL(const TDesC &, TDes &)
IMPORT_C
TInt
|
SelectTextL
|
(
|
const
TDesC
&
|
aSqlStmt,
|
|
TDes
&
|
aDest
|
|
)
|
|
Executes a SELECT query which is expected to return a single row consisting of a single text value and copies that value to the place refered by aDest parameter.
If the destination buffer is not big enough, the function will copy as much data as possible and will return positive value - the character length of the text column.
-
leave
-
KErrNotFound, If there is no record, The function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
Parameters
const
TDesC
& aSqlStmt
|
16-bit SELECT sql query
|
TDes
& aDest
|
Refers to the place where the column data will be copied
|
SelectTextL(const TDesC8 &, TDes &)
Executes a SELECT query which is expected to return a single row consisting of a single text value and copies that value to the place refered by aDest parameter.
If the destination buffer is not big enough, the function will copy as much data as possible and will return positive value - the character length of the text column.
-
leave
-
KErrNotFound, If there is no record, The function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
Parameters
const
TDesC8
& aSqlStmt
|
8-bit SELECT sql query
|
TDes
& aDest
|
Refers to the place where the column data will be copied
|
SetDatabase(RSqlDatabase &)
Member Data Documentation
CSqlDatabaseImpl * iDatabaseImpl
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.