RSqlParamWriteStream Class Reference

#include <sqldb.h>

Link against: sqldb.lib

class RSqlParamWriteStream : public RWriteStream

Inherits from

  • RSqlParamWriteStream

    Detailed Description

    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);

    See also: RSqlBlobWriteStream TSqlBlob

    Member Function Documentation

    BindBinary ( RSqlStatement &, TInt )

    IMPORT_C TIntBindBinary(RSqlStatement &aStmt,
    TIntaParameterIndex
    )

    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()

    capability
    None
    ParameterDescription
    aStmtThe RSqlStatement object to which the referred parameter belongs.
    aParameterIndexThe 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.

    BindBinaryL ( RSqlStatement &, TInt )

    IMPORT_C voidBindBinaryL(RSqlStatement &aStmt,
    TIntaParameterIndex
    )

    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()).

    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.

    See also: RSqlStatement::Next() RSqlStatement::Exec()

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

    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()).

    See also: RSqlStatement::Next() RSqlStatement::Exec()

    capability
    None
    ParameterDescription
    aStmtThe RSqlStatement object to which the referred parameter belongs.
    aParameterIndexThe 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.

    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.

    See also: RSqlStatement::Next() RSqlStatement::Exec()

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