RSqlColumnReadStream Class Reference

#include <sqldb.h>

Link against: sqldb.lib

class RSqlColumnReadStream : public RReadStream

Inherits from

  • RSqlColumnReadStream

    Detailed Description

    The read stream interface.

    The class is used for reading the content of a column containing either binary data or text data.

    The class derives from RReadStream, which means that all RReadStream public member functions and predefined stream operators >> can be used to deal with column data.

    If the blob or text data 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 reading large amounts of blob or text data from a database.

    The following two cases are typical:

    CASE 1 - processing large binary column data.

    RSqlDatabase db;
    <open/create "db" object>;
    RSqlStatement stmt;
    <prepare "stmt" object>;
    TInt rc = stmt.Next();
    if(rc == KSqlAtRow)
    	{
    	RSqlColumnReadStream colStream;
    	CleanupClosePushL(colStream);
    	User::LeaveIfError(colStream.ColumnBinary(stmt, <column_number>));
    	TInt size = stmt.ColumnSize(<column_number>);
    	//read the column data in a buffer ("buf" variable).
    	//(or the column data can be retrieved in a smaller portions)
    	colStream.ReadL(buf, size);
    	//Close the stream
    	CleanupStack::PopAndDestroy(&colStream);
    	}
    else
    	{
    	...
    	}

    CASE 2 - processing large text column data.

    RSqlDatabase db;
    <open/create "db" object>;
    RSqlStatement stmt;
    <prepare "stmt" object>;
    TInt rc = stmt.Next();
    if(rc == KSqlAtRow)
    	{
    	RSqlColumnReadStream colStream;
    	CleanupClosePushL(colStream);
    	User::LeaveIfError(colStream.ColumnText(stmt, <column_number>));
    	TInt size = stmt.ColumnSize(<column_number>);
    	//read the column data in a buffer ("buf" variable).
    	//(or the column data can be retrieved in a smaller portions)
    	colStream.ReadL(buf, size);
    	//Close the stream
    	CleanupStack::PopAndDestroy(&colStream);
    	}
    else
    	{
    	...
    	}

    See also: RSqlBlobReadStream TSqlBlob

    Member Function Documentation

    ColumnBinary ( RSqlStatement &, TInt )

    IMPORT_C TIntColumnBinary(RSqlStatement &aStmt,
    TIntaColumnIndex
    )

    Gives access to column data as a read-only stream of bytes.

    The function can only be used for text and binary column types.

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

    Returns: KErrNone, the text column data stream has been opened successfully; KErrNoMemory, an out of memory condition occurred; KErrArgument, the column type is neither text nor binary. Note that database specific errors categorised as ESqlDbError, and other system-wide error codes may also be returned.

    ColumnBinaryL ( RSqlStatement &, TInt )

    IMPORT_C voidColumnBinaryL(RSqlStatement &aStmt,
    TIntaColumnIndex
    )

    Gives access to column data as a read-only stream of bytes.

    The function can only be used for text and binary column types.

    leave
    KErrNoMemory, an out of memory condition occurred; KErrArgument, the column type is neither text nor binary. Note that database specific errors categorised as ESqlDbError, and other system-wide error codes may also be returned.
    capability
    None
    ParameterDescription
    aStmtThe RSqlStatement object to which the referred column belongs.
    aColumnIndexThe index value identifying the column; this is 0 for the first column.

    ColumnText ( RSqlStatement &, TInt )

    IMPORT_C TIntColumnText(RSqlStatement &aStmt,
    TIntaColumnIndex
    )

    Gives access to column data as a read-only stream of characters,

    The function can only be used for text and binary column types.

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

    Returns: KErrNone, the text column data stream has been opened successfully; KErrNoMemory, an out of memory condition occurred; KErrArgument, the column type is neither text nor binary. Note that database specific errors categorised as ESqlDbError, and other system-wide error codes may also be returned.

    ColumnTextL ( RSqlStatement &, TInt )

    IMPORT_C voidColumnTextL(RSqlStatement &aStmt,
    TIntaColumnIndex
    )

    Gives access to column data as a read-only stream of characters,

    The function can only be used for text and binary column types.

    leave
    KErrNoMemory, an out of memory condition occurred; KErrArgument, the column type is neither text nor binary. Note that database specific errors categorised as ESqlDbError, and other system-wide error codes may also be returned.
    capability
    None
    ParameterDescription
    aStmtThe RSqlStatement object to which the referred column belongs.
    aColumnIndexThe index value identifying the column; this is 0 for the first column.