#include <sqldb.h>
class RSqlParamWriteStream : public RWriteStream |
Public Member Functions | |
---|---|
IMPORT_C TInt | BindBinary(RSqlStatement &, TInt) |
IMPORT_C void | BindBinaryL(RSqlStatement &, TInt) |
IMPORT_C TInt | BindText(RSqlStatement &, TInt) |
IMPORT_C void | BindTextL(RSqlStatement &, TInt) |
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(¶mStream);
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(¶mStream);
See also: RSqlBlobWriteStream TSqlBlob
IMPORT_C TInt | BindBinary | ( | RSqlStatement & | aStmt, |
TInt | aParameterIndex | |||
) |
Gives access to parameter data as a stream of bytes.
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()).
See also: RSqlStatement::Next() RSqlStatement::Exec()
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred parameter belongs. |
aParameterIndex | The index value identifying the parameter; this is 0 for the first parameter. |
Returns: KErrNone, the binary parameter data stream has been opened successfully; 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.
IMPORT_C void | BindBinaryL | ( | RSqlStatement & | aStmt, |
TInt | aParameterIndex | |||
) |
Gives access to parameter data as a stream of bytes.
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()).
See also: RSqlStatement::Next() RSqlStatement::Exec()
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred parameter belongs. |
aParameterIndex | The index value identifying the parameter; this is 0 for the first parameter. |
IMPORT_C TInt | BindText | ( | RSqlStatement & | aStmt, |
TInt | aParameterIndex | |||
) |
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()).
See also: RSqlStatement::Next() RSqlStatement::Exec()
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred parameter belongs. |
aParameterIndex | The index value identifying the parameter; this is 0 for the first parameter. |
Returns: KErrNone, the binary parameter data stream has been opened successfully; 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.
IMPORT_C void | BindTextL | ( | RSqlStatement & | aStmt, |
TInt | aParameterIndex | |||
) |
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()).
See also: RSqlStatement::Next() RSqlStatement::Exec()
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred parameter belongs. |
aParameterIndex | The index value identifying the parameter; this is 0 for the first parameter. |