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(¶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);
Public Member Functions | |
---|---|
IMPORT_C void | BindBinaryL(RSqlStatement &, TInt) |
IMPORT_C TInt | BindText(RSqlStatement &, TInt) |
IMPORT_C void | BindTextL(RSqlStatement &, TInt) |
IMPORT_C void | BindBinaryL | ( | RSqlStatement & | aStmt, |
TInt | aParameterIndex | |||
) |
RSqlStatement & aStmt | |
TInt aParameterIndex |
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()).
RSqlStatement & aStmt | The RSqlStatement object to which the referred parameter belongs. |
TInt aParameterIndex | The index value identifying the parameter; this is 0 for the first parameter. |
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()).
RSqlStatement & aStmt | The RSqlStatement object to which the referred parameter belongs. |
TInt aParameterIndex | The index value identifying the parameter; this is 0 for the first parameter. |
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.