#include <sqldb.h>
class RSqlColumnReadStream : public RReadStream |
Public Member Functions | |
---|---|
IMPORT_C TInt | ColumnBinary(RSqlStatement &, TInt) |
IMPORT_C void | ColumnBinaryL(RSqlStatement &, TInt) |
IMPORT_C TInt | ColumnText(RSqlStatement &, TInt) |
IMPORT_C void | ColumnTextL(RSqlStatement &, TInt) |
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
IMPORT_C TInt | ColumnBinary | ( | RSqlStatement & | aStmt, |
TInt | aColumnIndex | |||
) |
Gives access to column data as a read-only stream of bytes.
The function can only be used for text and binary column types.
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred column belongs. |
aColumnIndex | The 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.
IMPORT_C void | ColumnBinaryL | ( | RSqlStatement & | aStmt, |
TInt | aColumnIndex | |||
) |
Gives access to column data as a read-only stream of bytes.
The function can only be used for text and binary column types.
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred column belongs. |
aColumnIndex | The index value identifying the column; this is 0 for the first column. |
IMPORT_C TInt | ColumnText | ( | RSqlStatement & | aStmt, |
TInt | aColumnIndex | |||
) |
Gives access to column data as a read-only stream of characters,
The function can only be used for text and binary column types.
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred column belongs. |
aColumnIndex | The 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.
IMPORT_C void | ColumnTextL | ( | RSqlStatement & | aStmt, |
TInt | aColumnIndex | |||
) |
Gives access to column data as a read-only stream of characters,
The function can only be used for text and binary column types.
Parameter | Description |
---|---|
aStmt | The RSqlStatement object to which the referred column belongs. |
aColumnIndex | The index value identifying the column; this is 0 for the first column. |