RSqlStatement Class Reference

class RSqlStatement

Represents an SQL statement.

An object of this type can be used to execute all types of SQL statements; this includes SQL statements with parameters.

If a SELECT statament is passed to RSqlStatement::Prepare(), then the returned record set is forward only, non-updateable.

There are a number of ways that this object is used; here are some examples.

CASE 1 - the execution of a SQL statement, which does not return record set:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = stmt.Prepare(database, _L("INSERT INTO Tbl1(Fld1) VALUES(:Val)"));
TInt paramIndex = stmt.ParameterIndex(_L(":Val"));
for(TInt i=1;i<=10;++i)
	{
	err = stmt.BindInt(paramIndex, i);
	err = stmt.Exec();
	err = stmt.Reset();
	}
stmt.Close();

The following pseudo code shows the general pattern:

<RSqlStatement::Prepare()>
[begin:]
<RSqlStatement::Bind<param_type>()>
<RSqlStatement::Exec()>
[<RSqlStatement::Reset()>]
[<RSqlStatement::Bind<param_type>()>]
[<Goto :begin>]

CASE 2 - the execution of a SQL statement, which returns a record set:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = stmt.Prepare(database, _L("SELECT Fld1 FROM Tbl1 WHERE Fld1 > :Val"));
TInt paramIndex = stmt.ParameterIndex(_L(":Val"));
err = stmt.BindInt(paramIndex, 5);
TInt columnIndex = stmt.ColumnIndex(_L("Fld1"));
while((err = stmt.Next()) == KSqlAtRow)
	{
	TInt val = stmt.ColumnInt(columnIndex);
	RDebug::Print(_L("val=%d\n"), val);
	}
if(err == KSqlAtEnd)
	<OK - no more records>;
else
	<process the error>;
stmt.Close();

The following pseudo code shows the general pattern:

<RSqlStatement::Prepare()>
[begin:]
<while (RSqlStatement::Next() == KSqlAtRow)>
	<do something with the records>
if(err == KSqlAtEnd)
	<OK - no more records>;
else
	<process the error>;
[<RSqlStatement::Reset()>]
[<RSqlStatement::Bind<param_type>()>]
[<Goto begin>]

CASE 3.1 - SELECT statements: large column data processing, where the data is copied into a buffer supplied by the client:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
while((err = stmt.Next()) == KSqlAtRow)
	{
	TInt size = stmt. ColumnSize(columnIndex);
	HBufC8* buf = HBufC8::NewL(size);
	err = stmt.ColumnBinary(columnIndex, buf->Ptr());
	<do something with the data>;
	delete buf;
	}
if(err == KSqlAtEnd)
	<OK - no more records>;
else
	<process the error>;
stmt.Close();

CASE 3.2 - SELECT statements: large column data processing, where the data is accessed by the client without copying:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
while((err = stmt.Next()) == KSqlAtRow)
	{
	TPtrC8 data = stmt.ColumnBinaryL(columnIndex);
	<do something with the data>;
	}
if(err == KSqlAtEnd)
	<OK - no more records>;
else
	<process the error>;
stmt.Close();

CASE 3.3 - SELECT statements, large column data processing (the data is accessed by the client without copying), leaving-safe processing:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
while((err = stmt.Next()) == KSqlAtRow)
	{
	TPtrC8 data;
	TInt err = stmt.ColumnBinary(columnIndex, data);
	if(err == KErrNone)
		{
		<do something with the data>;
		}
	}
if(err == KSqlAtEnd)
	<OK - no more records>;
else
	<process the error>;
stmt.Close();

CASE 3.4 - SELECT statements: large column data processing, where the data is accessed by the client using a stream:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = stmt.Prepare(database, _L("SELECT BinaryField FROM Tbl1"));
TInt columnIndex = stmt.ColumnIndex(_L("BinaryField"));
while((err = stmt.Next()) == KSqlAtRow)
	{
	RSqlColumnReadStream stream;
	err = stream.ColumnBinary(stmt, columnIndex);
	<do something with the data in the stream>;
	stream.Close();
	}
if(err == KSqlAtEnd)
	<OK - no more records>;
else
	<process the error>;
stmt.Close();

CASE 4 - the execution of a SQL statement with parameter(s), some of which may be large text or binary values:

RSqlDatabase database;
.........
RSqlStatement stmt;
TInt err = 
	stmt.Prepare(database, _L("UPDATE Tbl1 SET LargeTextField = :LargeTextVal WHERE IdxField = :KeyVal"));
TInt paramIndex1 = stmt.ParameterIndex(_L(":LargeTextVal"));
TInt paramIndex2 = stmt.ParameterIndex(_L(":KeyVal"));
for(TInt i=1;i<=10;++i)
	{
	RSqlParamWriteStream stream;
	err = stream.BindText(stmt, paramIndex1);
	<insert large text data into the stream>;
	stream.Close();
	err = stmt.BindInt(paramIndex2, i);
	err = stmt.Exec();
	stmt.Reset();
	}
stmt.Close();

The following table shows what is returned when the caller uses a specific column data retrieving function on a specific column type.

--------------------------------------------------------------------------------
Column type | ColumnInt() ColumnInt64() ColumnReal() ColumnText() ColumnBinary()
--------------------------------------------------------------------------------
Null........|.0...........0.............0.0..........KNullDesC....KNullDesC8
Int.........|.Int.........Int64.........Real.........KNullDesC....KNullDesC8 
Int64.......|.clamp.......Int64.........Real.........KNullDesC....KNullDesC8 
Real........|.round.......round.........Real.........KNullDesC....KNullDesC8 
Text........|.0...........0.............0.0..........Text.........KNullDesC8   
Binary......|.0...........0.............0.0..........KNullDesC....Binary
--------------------------------------------------------------------------------
Note the following definitions:
  • "clamp": return KMinTInt or KMaxTInt if the value is outside the range that can be represented by the type returned by the accessor function.

  • "round": the floating point value will be rounded up to the nearest integer. If the result is outside the range that can be represented by the type returned by the accessor function, then it will be clamped.

Note that when handling blob and text data over 2Mb in size it is recommended that the RSqlBlobReadStream and RSqlBlobWriteStream classes or the TSqlBlob class is used instead. These classes provide a more RAM-efficient way of reading and writing large amounts of blob or text data from a database.

KMinTInt KMaxTInt KNullDesC KNullDesC8 RSqlBlobReadStream RSqlBlobWriteStream TSqlBlob

Public Member Functions
RSqlStatement()
IMPORT_C TIntBindInt64(TInt, TInt64)
IMPORT_C TIntBindNull(TInt)
IMPORT_C TIntBindReal(TInt, TReal)
IMPORT_C TIntBindText(TInt, const TDesC &)
IMPORT_C TIntBindZeroBlob(TInt, TInt)
IMPORT_C voidClose()
IMPORT_C TIntColumnBinary(TInt, TPtrC8 &)
IMPORT_C TIntColumnBinary(TInt, TDes8 &)
IMPORT_C TPtrC8ColumnBinaryL(TInt)
IMPORT_C TIntColumnIndex(const TDesC &)
IMPORT_C TInt64ColumnInt64(TInt)
IMPORT_C TIntColumnName(TInt, TPtrC &)
IMPORT_C TRealColumnReal(TInt)
IMPORT_C TIntColumnSize(TInt)
IMPORT_C TIntColumnText(TInt, TPtrC &)
IMPORT_C TIntColumnText(TInt, TDes &)
IMPORT_C TPtrCColumnTextL(TInt)
IMPORT_C TSqlColumnTypeColumnType(TInt)
IMPORT_C TIntDeclaredColumnType(TInt, TSqlColumnType &)
IMPORT_C TIntExec()
IMPORT_C TBoolIsNull(TInt)
IMPORT_C TIntNext()
IMPORT_C TIntParamName(TInt, TPtrC &)
IMPORT_C TIntParameterIndex(const TDesC &)
IMPORT_C TIntParameterName(TInt, TPtrC &)
IMPORT_C TIntPrepare(RSqlDatabase &, const TDesC &)
IMPORT_C voidPrepareL(RSqlDatabase &, const TDesC &)
IMPORT_C voidPrepareL(RSqlDatabase &, const TDesC8 &)
IMPORT_C TIntReset()
Private Member Functions
CSqlStatementImpl &Impl()
Private Attributes
CSqlStatementImpl *iImpl

Constructor & Destructor Documentation

RSqlStatement()

IMPORT_CRSqlStatement()

Initialises the pointer to the implementation object to NULL.

capability
None

Member Functions Documentation

BindInt64(TInt, TInt64)

IMPORT_C TIntBindInt64(TIntaParameterIndex,
TInt64aParameterValue
)

Sets the parameter to the specified 64-bit integer value.

The parameter is identified by the specified index value.

A parameter value can be set:
  • immediately after this SQL statement has been prepared

  • after a call to Reset()

RSqlStatement::Prepare() RSqlStatement::Reset()
panic
SqlDb 5 Parameter index out of bounds.
capability
None

Parameters

TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.
TInt64 aParameterValueThe 64-bit integer value to be assigned to the parameter.

BindNull(TInt)

IMPORT_C TIntBindNull(TIntaParameterIndex)

Sets the parameter to a NULL value.

The parameter is identified by the specified index value.

A parameter value can be set:
  • immediately after this SQL statement has been prepared

  • after a call to Reset()

RSqlStatement::Prepare() RSqlStatement::Reset()
panic
SqlDb 5 Parameter index out of bounds.
capability
None

Parameters

TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.

BindReal(TInt, TReal)

IMPORT_C TIntBindReal(TIntaParameterIndex,
TRealaParameterValue
)

Sets the parameter to the specified 64-bit floating point value.

The parameter is identified by the specified index value.

A parameter value can be set:
  • immediately after this SQL statement has been prepared

  • after a call to Reset()

RSqlStatement::Prepare() RSqlStatement::Reset()
panic
SqlDb 5 Parameter index out of bounds.
capability
None

Parameters

TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.
TReal aParameterValueThe 64-bit floating point value to be assigned to the parameter.

BindText(TInt, const TDesC &)

IMPORT_C TIntBindText(TIntaParameterIndex,
const TDesC &aParameterText
)

Sets the parameter to the specified 16-bit descriptor.

The parameter is identified by the specified index value.

A parameter value can be set:
  • immediately after this SQL statement has been prepared

  • after a call to Reset()

Note that when the text data to be bound is over 2Mb in size then use of the RSqlBlobWriteStream or TSqlBlob class should be considered instead.

These classes provide a more RAM-efficient way of writing large amounts of text data to a database, however no conversions are performed on the text data - it is simply stored as a stream of bytes. If the text data is part of a record to be inserted into a database then BindZeroBlob() should be called on the INSERT statement to create a placeholder for the text data, whose content can then be written using the above classes.

Parameters

TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.
const TDesC & aParameterTextThe 16-bit descriptor whose content is to be assigned to the parameter.

BindZeroBlob(TInt, TInt)

IMPORT_C TIntBindZeroBlob(TIntaParameterIndex,
TIntaBlobSize
)

Binds a blob of length aBlobSize bytes that is filled with zeroes.

The parameter is identified by the specified index value.

A parameter value can be set:
  • immediately after this SQL statement has been prepared

  • after a call to Reset()

A zeroblob acts as a placeholder for a blob whose binary content is later written using the RSqlBlobWriteStream or TSqlBlob class.

Using zeroblobs provides a much more RAM-efficient way of creating large blobs than including the blob data in the INSERT statement and it is recommended for blobs that are over 2Mb in size.

Note that a zeroblob should be created in a column after which there are no columns that contain anything other than zeroblobs or NULLs, otherwise the zeroblob must be allocated in full in RAM and its benefit is lost.

When creating a zeroblob it is recommended, where possible, to create the zeroblob and then write the blob content (using the RSqlBlobWriteStream or TSqlBlob class) within the same transaction. Otherwise the zeroblob will have to be journalled before being written to.

Parameters

TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.
TInt aBlobSizeThe size in bytes of the blob.

Close()

IMPORT_C voidClose()

ColumnBinary(TInt, TPtrC8 &)

IMPORT_C TIntColumnBinary(TIntaColumnIndex,
TPtrC8 &aPtr
)const

Parameters

TInt aColumnIndex
TPtrC8 & aPtr

ColumnBinary(TInt, TDes8 &)

IMPORT_C TIntColumnBinary(TIntaColumnIndex,
TDes8 &aDest
)const

Parameters

TInt aColumnIndex
TDes8 & aDest

ColumnBinaryL(TInt)

IMPORT_C TPtrC8ColumnBinaryL(TIntaColumnIndex)const

Gets the value of the column as an 8-bit descriptor (leaves on failure).

The column is identified by the specified index value.

Note that the function can only be called after a successful call to Next(), i.e. after a call to Next() that has completed with a KSqlAtRow return code. Calling this function after an unsuccessful call to Next() raises a panic.

Note that when the binary data to be retrieved is over 2Mb in size then it is recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. These classes provide a more RAM-efficient way of retrieving large amounts of binary data from a database.

leave
KErrNoMemory if the operation for retrieving the column value from the server fails with an out of memory condition.
KSqlAtRow RSqlStatement::ColumnBinary() RSqlStatement::Prepare() RSqlStatement::Next() RSqlBlobReadStream TSqlBlob
panic
SqlDb 5 Column index out of bounds.
panic
SqlDb 11 Statement cursor not positioned on a row
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column; this is 0 for the first column.

ColumnIndex(const TDesC &)

IMPORT_C TIntColumnIndex(const TDesC &aColumnName)const

Gets the index (starting from 0) of the column with the given name.

The function does a case insensitive column name search.

This function can be called at any time after the SQL statement has been prepared.

capability
None

Parameters

const TDesC & aColumnNameThe column name.

ColumnInt64(TInt)

IMPORT_C TInt64ColumnInt64(TIntaColumnIndex)const

Gets the value of the column as a 64-bit integer.

The column is identified by the specified index value.

Note that the function can only be called after a successful call to Next(), i.e. after a call to Next() that has completed with a KSqlAtRow return code. Calling this function after an unsuccessful call to Next() raises a panic.

KSqlAtRow RSqlStatement::Prepare() RSqlStatement::Next()
panic
SqlDb 5 Column index out of bounds.
panic
SqlDb 11 Statement cursor not positioned on a row
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column; this is 0 for the first column.

ColumnName(TInt, TPtrC &)

IMPORT_C TIntColumnName(TIntaColumnIndex,
TPtrC &aNameDest
)

Obtain the name of a column after preparing a query.

capability
None

Parameters

TInt aColumnIndexColumn index
TPtrC & aNameDestDescriptor which will be set to column name

ColumnReal(TInt)

IMPORT_C TRealColumnReal(TIntaColumnIndex)const

Gets the value of the column as a 64-bit floating point value.

The column is identified by the specified index value.

Note that the function can only be called after a successful call to Next(), i.e. after a call to Next() that has completed with a KSqlAtRow return code. Calling this function after an unsuccessful call to Next() raises a panic.

KSqlAtRow RSqlStatement::Prepare() RSqlStatement::Next()
panic
SqlDb 5 Column index out of bounds.
panic
SqlDb 11 Statement cursor not positioned on a row
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column; this is 0 for the first column.

ColumnSize(TInt)

IMPORT_C TIntColumnSize(TIntaColumnIndex)const

Parameters

TInt aColumnIndex

ColumnText(TInt, TPtrC &)

IMPORT_C TIntColumnText(TIntaColumnIndex,
TPtrC &aPtr
)const

Parameters

TInt aColumnIndex
TPtrC & aPtr

ColumnText(TInt, TDes &)

IMPORT_C TIntColumnText(TIntaColumnIndex,
TDes &aDest
)const

Parameters

TInt aColumnIndex
TDes & aDest

ColumnTextL(TInt)

IMPORT_C TPtrCColumnTextL(TIntaColumnIndex)const

Gets the value of the column as a 16-bit descriptor (leaves on failure).

The column is identified by the specified index value.

Note that the function can only be called after a successful call to Next(), i.e. after a call to Next() that has completed with a KSqlAtRow return code. Calling this function after an unsuccessful call to Next() raises a panic.

Note that when the text to be retrieved is over 2Mb in size then it is recommended that the RSqlBlobReadStream or TSqlBlob class is used instead. These classes provide a more RAM-efficient way of retrieving large amounts of text data from a database.

leave
KErrNoMemory if the operation for retrieving the column value from the server fails with an out of memory condition.
KSqlAtRow RSqlStatement::ColumnText() RSqlStatement::Prepare() RSqlStatement::Next() RSqlBlobReadStream TSqlBlob
panic
SqlDb 5 Column index out of bounds.
panic
SqlDb 11 Statement cursor not positioned on a row
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column; this is 0 for the first column.

ColumnType(TInt)

IMPORT_C TSqlColumnTypeColumnType(TIntaColumnIndex)const

Gets the runtime type of the column identified by the specified column index.

This function returns the actual runtime datatype of the specified column as opposed to its declared type.

Note that the function can only be called after a successful call to Next(), i.e. after a call to Next() that has completed with a KSqlAtRow return code. Calling this function after an unsuccessful call to Next() raises a panic.

KSqlAtRow TSqlColumnType RSqlStatement::DeclaredColumnType() RSqlStatement::Next() RSqlStatement::ColumnIndex()
panic
SqlDb 5 Column index out of bounds.
panic
SqlDb 11 Statement cursor not positioned on a row.
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column; this is 0 for the first column.

DeclaredColumnType(TInt, TSqlColumnType &)

IMPORT_C TIntDeclaredColumnType(TIntaColumnIndex,
TSqlColumnType &aColumnType
)const

Gets the declared type of the column identified by the specified column index.

Note that the function can only be called when executing a SELECT query, and only after a successful call to Prepare().

This function returns the datatype that the specified column was originally declared to have.

The declared type of a column is determined according to the following rules:
 - if the column type name contains the string "INT", then the declared column type is ESqlInt;
 - if the column type name contains any of the strings "CHAR, "TEXT" or "CLOB", then the declared column type is ESqlText;
 - if the column type name contains any of the strings "BLOB" or "BINARY", then the declared column type is ESqlBinary;
 - if the column type name contains any of the strings "FLOAT", "REAL" or "DOUBLE", then the declared column type is ESqlReal;
 - in all other cases the declared column type is assumed to be ESqlInt;
TSqlColumnType RSqlStatement::ColumnType() RSqlStatement::ColumnIndex()
panic
SqlDb 5 Column index out of bounds.
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column. This is 0 for the first column.
TSqlColumnType & aColumnTypeOutput parameter. If the call completes successfully, aColumnType contains the type of the column, one of TSqlColumnType enum item values.

Exec()

IMPORT_C TIntExec()

Impl()

CSqlStatementImpl &Impl()const [private]

Returns a reference to the implementation object of RSqlStatement - CSqlStatementImpl.

panic
SqlDb 2 The SQL statement has not been prepared, i.e. Prepare() has not yet been called on this RSqlStatement object.

IsNull(TInt)

IMPORT_C TBoolIsNull(TIntaColumnIndex)const

Tests whether the value of the specified column is NULL.

The column is identified by the specified index value.

Note that the function can only be called after a successful call to Next(), i.e. after a call to Next() that has completed with a KSqlAtRow return code. Calling this function after an unsuccessful call to Next() raises a panic.

KSqlAtRow RSqlStatement::Prepare() RSqlStatement::Next()
panic
SqlDb 5 Column index out of bounds.
panic
SqlDb 11 Statement cursor not positioned on a row
capability
None

Parameters

TInt aColumnIndexThe index value identifying the column; this is 0 for the first column.

Next()

IMPORT_C TIntNext()

Retrieves a record.

If the prepared SQL statement is a "SELECT" statement, and is expected to return a set of records, then this function can be used to retrieve that record data.

If the SQL statement contains parameters, then their values must be bound before this function is called.

If the call to this function completes successfully, i.e. it returns with KSqlAtRow, then this RSqlStatement object contains the record data, and this data will remain valid for access until another call is made to any RSqlStatement function.

Note that if this call to Next() fails, as indicated by a return code value other than KSqlAtRow, then calls to these RSqlStatement::Column...() functions will raise a panic.

capability
None

ParamName(TInt, TPtrC &)

IMPORT_C TIntParamName(TIntaParameterIndex,
TPtrC &aNameDest
)

Obtain the name of a parameter after preparing a DML query. The parameter names are returned in exactly the same form as supplied in SQL statement. For example, if the parameter name is ":Prm", then the ":" prefix will not be omitted.

ParamName has the same behaviour as ParameterName. It is provided to maintain source compatibility with previous Symbian releases.

This function can be called at any time after the DML SQL statement has been prepared.

capability
None

Parameters

TInt aParameterIndexParameter index
TPtrC & aNameDestDescriptor which will be set to parameter name

ParameterIndex(const TDesC &)

IMPORT_C TIntParameterIndex(const TDesC &aParameterName)const

Gets the index (starting from 0) of the parameter with the given name.

The function does a case insensitive parameter name search.

For example, if the parameter name is ":Prm", then the ":" prefix cannot be omitted when you call ParameterIndex().

This function can be called at any time after the SQL statement has been prepared.

capability
None

Parameters

const TDesC & aParameterNameThe parameter name.

ParameterName(TInt, TPtrC &)

IMPORT_C TIntParameterName(TIntaParameterIndex,
TPtrC &aNameDest
)

Obtain the name of a parameter after preparing a DML query. The parameter names are returned in exactly the same form as supplied in SQL statement. For example, if the parameter name is ":Prm", then the ":" prefix will not be omitted.

This function can be called at any time after the DML SQL statement has been prepared.

capability
None

Parameters

TInt aParameterIndexParameter index
TPtrC & aNameDestDescriptor which will be set to column name

Prepare(RSqlDatabase &, const TDesC &)

IMPORT_C TIntPrepare(RSqlDatabase &aDatabase,
const TDesC &aSqlStmt
)

Parameters

RSqlDatabase & aDatabase
const TDesC & aSqlStmt

PrepareL(RSqlDatabase &, const TDesC &)

IMPORT_C voidPrepareL(RSqlDatabase &aDatabase,
const TDesC &aSqlStmt
)

Prepares the supplied 16-bit SQL statement for execution.

An RSqlStatement object can prepare and execute a parameterised SQL statement or an SQL statement without parameters.

The function can only deal with one SQL statement at a time, i.e. if you supply more than one SQL statement, each separated by a ";" character, then the function returns an error.

Note that when the statement is to be used to retrieve or write blob or text data that is over 2Mb in size then it is recommended that the RSqlBlobReadStream and RSqlBlobWriteStream classes or the TSqlBlob class is used instead. These classes provide a more RAM-efficient way of reading and writing large amounts of blob or text data from a database.

leave
KErrNoMemory, an out of memory condition has occurred; KErrArgument, the SQL statement is invalid, for example, the supplied string contains more than one SQL statement, or it contains an empty SQL statement. Note that database specific errors categorised as ESqlDbError can also be returned; KSqlErrGeneral, a syntax error has occurred - text describing the problem can be obtained by calling RSqlDatabase::LastErrorMessage(). KErrPermissionDenied, the calling application does not satisfy the relevant database security policies. Note that the function may leave with database specific errors categorised as ESqlDbError and other system-wide error codes.
capability
None, if current RSqlStatement object represents a handle which operates on a non-secure database; RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement modifies a secure database schema; RSqlSecurityPolicy::EReadPolicy or RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement reads from a secure database; RSqlSecurityPolicy::EWritePolicy or RSqlSecurityPolicy::ESchemaPolicy database policy type, if the SQL statement writes to a secure database;
TSqlRetCodeClass::ESqlDbError RSqlDatabase RSqlDatabase::LastErrorMessage() RSqlSecurityPolicy RSqlSecurityPolicy::TPolicyType RSqlBlobReadStream RSqlBlobWriteStream TSqlBlob

Parameters

RSqlDatabase & aDatabaseA reference to the RSqlDatabase object that represents the database for which the SQL statement is being prepared.
const TDesC & aSqlStmtA string of 16-bit wide characters containing the SQL statement to be prepared.

PrepareL(RSqlDatabase &, const TDesC8 &)

IMPORT_C voidPrepareL(RSqlDatabase &aDatabase,
const TDesC8 &aSqlStmt
)

Parameters

RSqlDatabase & aDatabase
const TDesC8 & aSqlStmt

Reset()

IMPORT_C TIntReset()

Resets the prepared SQL statement to its initial state and makes it ready to be executed again.

Any SQL statement parameters that had values bound to them, retain their values.

If this object processes a parameterised SQL statement, then the parameter values can be bound after the call to Reset().

If the call to this function fails because of a database-specific type error (i.e. the error is categorised as of type ESqlDbError), then a textual description of the error can be obtained calling RSqlDatabase::LastErrorMessage().

Usage pattern 1:

RSqlStatement stmt;
TInt err = stmt.Prepare(<database>, <SQL statement>);
while(<condition>)
	{
	err = stmt.Bind<parameter type>(<parameter index>, <value>);
	...
	err = stmt.Exec();
	....
	err = stmt.Reset();
	}
stmt.Close();

Usage pattern 2:

RSqlStatement stmt;
TInt err = stmt.Prepare(<database>, <SQL statement>);
while(<condition>)
	{
	err = stmt.Bind<parameter type>(<parameter index>, <value>);
	...
	while((err = stmt.Next()) == KSqlAtRow)
		{
		....
		}
	err = stmt.Reset();
	}
stmt.Close();

Member Data Documentation

CSqlStatementImpl * iImpl

CSqlStatementImpl *iImpl[private]