RSqlColumnReadStream Class Reference

class RSqlColumnReadStream : public RReadStream

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
	{
	...
	}

RSqlBlobReadStream TSqlBlob

Inherits from

Member Functions Documentation

ColumnBinaryL(RSqlStatement &, TInt)

IMPORT_C voidColumnBinaryL(RSqlStatement &aStmt,
TIntaColumnIndex
)

Parameters

RSqlStatement & aStmt
TInt aColumnIndex

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

Parameters

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

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

Parameters

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