TSqlScalarFullSelectQuery Class Reference

#include <sqldb.h>

class TSqlScalarFullSelectQuery
Public Member Functions
TSqlScalarFullSelectQuery()
TSqlScalarFullSelectQuery(RSqlDatabase &)
IMPORT_C TIntSelectBinaryL(const TDesC &, TDes8 &)
IMPORT_C TIntSelectBinaryL(const TDesC8 &, TDes8 &)
IMPORT_C TInt64SelectInt64L(const TDesC &)
IMPORT_C TInt64SelectInt64L(const TDesC8 &)
IMPORT_C TIntSelectIntL(const TDesC &)
IMPORT_C TIntSelectIntL(const TDesC8 &)
IMPORT_C TRealSelectRealL(const TDesC &)
IMPORT_C TRealSelectRealL(const TDesC8 &)
IMPORT_C TIntSelectTextL(const TDesC &, TDes &)
IMPORT_C TIntSelectTextL(const TDesC8 &, TDes &)
IMPORT_C voidSetDatabase(RSqlDatabase &)

Detailed Description

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

See also: RSqlDatabase

Constructor & Destructor Documentation

TSqlScalarFullSelectQuery ( )

IMPORT_CTSqlScalarFullSelectQuery()

Initializes TSqlScalarFullSelectQuery data members with default values.

TSqlScalarFullSelectQuery ( RSqlDatabase & )

IMPORT_CTSqlScalarFullSelectQuery(RSqlDatabase &aDatabase)

Initializes TSqlScalarFullSelectQuery object.

ParameterDescription
aDatabaseA reference to the RSqlDatabase object that represents the database on which scalar fullselect queries will be executed.

Member Function Documentation

SelectBinaryL ( const TDesC &, TDes8 & )

IMPORT_C TIntSelectBinaryL(const TDesC &aSqlStmt,
TDes8 &aDest
)

Executes a SELECT query which is expected to return a single row consisting of a single binary 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 byte length of the binary 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.
ParameterDescription
aSqlStmt16-bit SELECT sql query
aDestRefers to the place where the column data will be copied

Returns: KErrNone, if the function completes successfully, Positive value, The binary column value length in bytes, in case if the receiving buffer is not big enough.

SelectBinaryL ( const TDesC8 &, TDes8 & )

IMPORT_C TIntSelectBinaryL(const TDesC8 &aSqlStmt,
TDes8 &aDest
)

Executes a SELECT query which is expected to return a single row consisting of a single binary 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.
ParameterDescription
aSqlStmt8-bit SELECT sql query
aDestRefers to the place where the column data will be copied

Returns: KErrNone, if the function completes successfully, Positive value, The binary column value length in bytes, in case if the receiving buffer is not big enough.

SelectInt64L ( const TDesC & )

IMPORT_C TInt64SelectInt64L(const TDesC &aSqlStmt)

Executes a SELECT query which is expected to return a single row consisting of a single 64-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.
ParameterDescription
aSqlStmt16-bit SELECT sql query

Returns: 64-bit integer column value.

SelectInt64L ( const TDesC8 & )

IMPORT_C TInt64SelectInt64L(const TDesC8 &aSqlStmt)

Executes a SELECT query which is expected to return a single row consisting of a single 64-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.
ParameterDescription
aSqlStmt8-bit SELECT sql query

Returns: 64-bit integer column value.

SelectIntL ( const TDesC & )

IMPORT_C TIntSelectIntL(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.
ParameterDescription
aSqlStmt16-bit SELECT sql query

Returns: 32-bit integer column value.

SelectIntL ( const TDesC8 & )

IMPORT_C TIntSelectIntL(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.
ParameterDescription
aSqlStmt8-bit SELECT sql query

Returns: 32-bit integer column value.

SelectRealL ( const TDesC & )

IMPORT_C TRealSelectRealL(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.
ParameterDescription
aSqlStmt16-bit SELECT sql query

Returns: Real column value.

SelectRealL ( const TDesC8 & )

IMPORT_C TRealSelectRealL(const TDesC8 &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.
ParameterDescription
aSqlStmt8-bit SELECT sql query

Returns: Real column value.

SelectTextL ( const TDesC &, TDes & )

IMPORT_C TIntSelectTextL(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.
ParameterDescription
aSqlStmt16-bit SELECT sql query
aDestRefers to the place where the column data will be copied

Returns: KErrNone, if the function completes successfully, Positive value, The text column value length in characters, in case if the receiving buffer is not big enough.

SelectTextL ( const TDesC8 &, TDes & )

IMPORT_C TIntSelectTextL(const TDesC8 &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.
ParameterDescription
aSqlStmt8-bit SELECT sql query
aDestRefers to the place where the column data will be copied

Returns: KErrNone, if the function completes successfully, Positive value, The text column value length in characters, in case if the receiving buffer is not big enough.

SetDatabase ( RSqlDatabase & )

IMPORT_C voidSetDatabase(RSqlDatabase &aDatabase)

Initializes/reinitializes TSqlScalarFullSelectQuery object.

ParameterDescription
aDatabaseA reference to the RSqlDatabase object that represents the database on which scalar fullselect queries will be executed.