RSqlParamWriteStream Class Reference

class RSqlParamWriteStream : public RWriteStream

The write stream interface.

The class is used to set binary data or text data into a parameter. This is a also known as binding a parameter.

The class derives from RWriteStream, which means that all RWriteStream public member functions and predefined stream operators << can be used to deal with the parameter data.

If the blob or text data is over 2Mb in size then it is recommended that the RSqlBlobWriteStream or TSqlBlob class is used instead. These classes provide a more RAM-efficient way of writing large amounts of blob or text data to a database.

The following two cases are typical:

CASE 1 - binding a large binary parameter.

RSqlDatabase db;
<open/create "db" object>;
RSqlStatement stmt;
<prepare "stmt" object>;//The SQL statement references large binary parameter
RSqlParamWriteStream paramStream;
CleanupClosePushL(paramStream);
User::LeaveIfError(paramStream.BindBinary(stmt, <parameter_number>));
//Write out the parameter data
paramStream.WriteL(..);
paramStream << <data>;
...
//Commit the stream
paramStream.CommitL();
//Continue with the statement processing issuing Next() or Exec().
TInt rc = stmt.Next();//rc = stmt.Exec()
//Close the stream
CleanupStack::PopAndDestroy(&paramStream);

CASE 2 - binding a large text parameter.

RSqlDatabase db;
<open/create "db" object>;
RSqlStatement stmt;
<prepare "stmt" object>;//The SQL statement references large text parameter
RSqlParamWriteStream paramStream;
CleanupClosePushL(paramStream);
User::LeaveIfError(paramStream.BindText(stmt, <parameter_number>));
//Write out the parameter data
paramStream.WriteL(..);
paramStream << <data>;
...
//Commit the stream
paramStream.CommitL();
//Continue with the statement processing issuing Next() or Exec().
TInt rc = stmt.Next();//rc = stmt.Exec()
//Close the stream
CleanupStack::PopAndDestroy(&paramStream);

RSqlBlobWriteStream TSqlBlob

Inherits from

Member Functions Documentation

BindBinaryL(RSqlStatement &, TInt)

IMPORT_C voidBindBinaryL(RSqlStatement &aStmt,
TIntaParameterIndex
)

Parameters

RSqlStatement & aStmt
TInt aParameterIndex

BindText(RSqlStatement &, TInt)

IMPORT_C TIntBindText(RSqlStatement &aStmt,
TIntaParameterIndex
)

Gives access to parameter data as a stream of characters.

NB You need to close the stream after the execution of the statement operation for which the parameter is set (RSqlStatement::Next() or RSqlStatement::Exec()).

Parameters

RSqlStatement & aStmtThe RSqlStatement object to which the referred parameter belongs.
TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.

BindTextL(RSqlStatement &, TInt)

IMPORT_C voidBindTextL(RSqlStatement &aStmt,
TIntaParameterIndex
)

Gives access to parameter data as a stream of characters.

NB You need to close the stream after the execution of the statement operation for which the parameter is set (RSqlStatement::Next() or RSqlStatement::Exec()).

leave
KErrNoMemory, an out of memory condition occurred. Note that database specific errors categorised as ESqlDbError, and other system-wide error codes may also be returned.
RSqlStatement::Next() RSqlStatement::Exec()
capability
None

Parameters

RSqlStatement & aStmtThe RSqlStatement object to which the referred parameter belongs.
TInt aParameterIndexThe index value identifying the parameter; this is 0 for the first parameter.