Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: COMMDB.H
Link against: commdb.lib

Class CCommsDbTableView

class CCommsDbTableView : public CBase;

Description

The view on a specific table in the database.

Includes the necessary behaviour for navigating through the records in the view and reading and writing to columns within a record.

Uses a CCommsDatabase and has an RDbView to read from and write to database. Created via CCommsDatabase::OpenTableLC() (which opens a view of all the records in the table) or one of the OpenViewLC...() functions (which open a specific view of the table):

CCommsDatabase::OpenTableLC()

CCommsDatabase::OpenViewMatchingUintLC()

CCommsDatabase::OpenViewMatchingBoolLC()

CCommsDatabase::OpenViewMatchingTextLC()

CCommsDatabase::OpenViewLC()

Note that the above five functions have been withdrawn in CCommsDatabase and are now implemented in CCommsDatabaseBase.

Derivation

Members

Defined in CCommsDbTableView:
CancelRecordChanges(), Database(), DeleteRecord(), GetTableName(), GotoFirstRecord(), GotoNextRecord(), GotoPreviousRecord(), InsertCopyRecord(), InsertRecord(), PutRecordChanges(), ReadBoolL(), ReadColumnLengthL(), ReadColumnMaxLengthL(), ReadLongTextLC(), ReadTextL(), ReadTextL(), ReadTypeAttribL(), ReadUintL(), SetNullL(), UpdateRecord(), WriteBoolL(), WriteLongTextL(), WriteTextL(), WriteTextL(), WriteUintL(), iDb, iTableExt, iTableName, iTableView, ~CCommsDbTableView()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


~CCommsDbTableView()

virtual IMPORT_C ~CCommsDbTableView();

Description

Frees all resources owned by this object, prior to its destruction. Specifically, it closes the view.

[Top]


Member functions


InsertRecord()

IMPORT_C TInt InsertRecord(TUint32 &aId);

Description

Prepares database to insert a new record and returns a unique ID for the record to be added.

PutRecordChanges() must be called to add the new entry.

This function sets the CCommsDbTableView onto the new record.

Once all changes to the new record are complete, a call must be made to either PutRecordChanges() or CancelRecordChanges() as appropriate.

This function raises a CommsDbServer 1 panic if a previous call to InsertRecord() or UpdateRecord() has already been made.

This function must be called before any attempt is made to write to a new column, otherwise subsequent write operations raise a CommsDbServer 12 panic.

Once this function has completed successfully, no attempt can be made to read from a column until either PutRecordChanges() or CancelRecordChanges() has been called to complete the record insertion operation, otherwise the read operations raise a CommsDbServer 10 panic.

Parameters

TUint32 &aId

On successful return, contains the unique Id associated with the new record.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.


InsertCopyRecord()

IMPORT_C TInt InsertCopyRecord(TUint32 &aId);

Description

Add a new record to this table. Filling all empty fields with values copied from record currently pointed at. The record number is returned. `PutRecordChanges()` is called to complete the transaction

Parameters

TUint32 &aId

Return value

TInt

See also


UpdateRecord()

IMPORT_C TInt UpdateRecord();

Description

Modify the current record of this view. `PutRecordChanges()` is called to complete the transaction

Return value

TInt


DeleteRecord()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C TInt DeleteRecord();

Description

Deletes the record in the table at the current cursor position.

This function raises a CommsDbServer 3 panic if a previous call to InsertRecord() or UpdateRecord() has been made.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

See also


PutRecordChanges()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C TInt PutRecordChanges(TBool aHidden=EFalse, TBool aReadOnly=EFalse);

Description

Confirms changes made to a record, which were started by calls to one of InsertRecord() or UpdateRecord().

The record can be marked as hidden by passing ETrue as a parameter. By default, records are not hidden.

A call to one of either InsertRecord() or UpdateRecord() must have previously been made otherwise the function raises a CommsDbServer 4 panic.

Parameters

TBool aHidden

Defines whether or not the record is to be marked as hidden. A true value means that the record is to be hidden. If not explicitly specified, EFalse is taken as default.

TBool aReadOnly

Defines whether or not the record is to be stored as read-only. Read-only storage prevents the record from being altered at a later time.

Return value

TInt

KErrNone if successful, otherwise another of the system-wide error codes.

See also


CancelRecordChanges()

IMPORT_C void CancelRecordChanges();

Description

Abandons changes made to a record which were started by calls to either:InsertRecord() or UpdateRecord().

A call to one of either InsertRecord() or UpdateRecord() must have previously been made otherwise the function raises a CommsDbServer 5 panic.


GotoFirstRecord()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C TInt GotoFirstRecord();

Description

Sets the first record in the view as the current record; i.e. set the view's cursor to point to the first record.

The CommsDbServer 6 panic is also raised if this function is called after the view has been closed.

This function must not be called if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 6 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

Return value

TInt

KErrNone if the record exists in the view and navigation is successful, KErrNotFound if the view is empty and has no records, otherwise another of the system-wide error codes.


GotoNextRecord()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C TInt GotoNextRecord();

Description

Sets the next record in the view as the current record; i.e. set the view's cursor to point to the next record.

This function must not be called if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 7 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

The CommsDbServer 7 panic is also raised if this function is called after the view has been closed.

Return value

TInt

KErrNone if the record exists in the view and navigation is successful, KErrNotFound if the current record is already the last in the view and there is no 'next' record, otherwise another of the system-wide error codes.

See also


GotoPreviousRecord()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C TInt GotoPreviousRecord();

Description

Sets the previous record in the view as the current record; i.e. set the view's cursor to point to the previous record.

This function must not be called if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 8 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

The CommsDbServer 8 panic is also raised if this function is called after the view has been closed.

Return value

TInt

KErrNone if the record exists in the view and navigation is successful, KErrNotFound if the current record is already the first in the view and there is no 'previous' record, otherwise another of the system-wide error codes.

See also


ReadTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadTextL(const TDesC &aColumn, TDes8 &aValue);

Description

Reads narrow (ASCII) text located in a specific column within the current record and copies it into an 8 bit modifiable descriptor. The column is identified by the name supplied in the descriptor aColumn.

If the column in the current record has a NULL value and the table has a template record, then the text located in the corresponding column in that template record is read and copied into aValue.

If the column in the current record has a NULL value and the table does not have a template record, then the length of the descriptor aValue is set to zero and the descriptor contains no text.

The maximum length of text expected by this function is the value of the constant KCommsDbSvrMaxColumnNameLength. The maximum length of aValue supplied by the caller can, therefore, be the same.

This read operation must not occur if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Note: If the column to be read is encrypted then the function decrypts it.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the current record whose (narrow text) value is to be read.

TDes8 &aValue

A reference to an 8 bit descriptor passed by the caller.

Leave codes

KErrNotFound

Specified column does not exist in the table.


ReadTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadTextL(const TDesC &aColumn, TDes16 &aValue);

Description

Reads wide (Unicode) text located in a specific column within the current record and copies it into a 16 bit modifiable descriptor. The column is identified by the name supplied in the descriptor aColumn.

If the column in the current record has a NULL value and the table has a template record, then the text located in the corresponding column in that template record is read and copied into aValue.

If the column in the current record has a NULL value and the table does not have a template record, then the length of the descriptor aValue is set to zero and the descriptor contains no text.

The maximum length of text expected by this function is the value of the constant KCommsDbSvrMaxColumnNameLength. The maximum length of aValue supplied by the caller can, therefore, be the same.

This read operation must not occur if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Note: If the column to be read is encrypted then the function decrypts it.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the current record whose (wide text) value is to be read.

TDes16 &aValue

A reference to a 16 bit descriptor passed by the caller.

Leave codes

KErrNotFound

Specified column does not exist in the table


ReadLongTextLC()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C HBufC *ReadLongTextLC(const TDesC &aColumn);

Description

Reads the long text located in a specific column within the current record and copies this text to a heap descriptor. The heap descriptor is allocated and its pointer returned by this function. The column is identified by the name supplied in the descriptor aColumn.

If the column in the current record has a NULL value and the table has a template record, then the long text located in the corresponding column in that template record is read and copied.

If the column in the current record has a NULL value and the table does not have a template record, then the length of the returned heap descriptor is zero and the descriptor contains no text.

While the text in columns retrieved by the ReadTextL() functions is limited in length, there is no restriction on the length of long text.

The HBufC* returned is left on the cleanup stack. The caller is responsible for calling CleanupStack::PopAndDestroy().

This read operation must not occur if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

Return value

HBufC *

Pointer to a heap descriptor containing the long text.

Leave codes

KErrNotFound

if the specified column does not exist in the table; KErrNoMemory if out of memory.

See also


ReadUintL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadUintL(const TDesC &aColumn, TUint32 &aValue);

Description

Reads an unsigned integer value located in a specific column within the current record and copies it into a reference to an unsigned integer. The column is identified by the name supplied in the descriptor aColumn.

If the column in the current record has a NULL value and the table has a template record, then the unsigned integer value located in the corresponding column in that template record is read and copied into aValue.

If the column in the current record has a NULL value and the table does not have a template record, then the function leaves.

This read operation must not occur if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the current record whose (unsigned integer) value is to be read.

TUint32 &aValue

A reference to an unsigned integer passed by the caller.

Leave codes

KErrUnknown

if the specified column is null; KErrNotFound if the specified column does not exist in the table.


ReadBoolL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadBoolL(const TDesC &aColumn, TBool &aValue);

Description

Reads a boolean value located in a specific column within the current record and copies it into a specified value. The column is identified by the name supplied in the descriptor aColumn.

If the column in the current record has a NULL value and the table has a template record, then the value located in the corresponding column in that template record is read and copied into aValue.

If the column in the current record has a NULL value and the table does not have a template record, then the function leaves.

This read operation must not occur if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the current record whose (boolean) value is to be read.

TBool &aValue

A reference to a TBool passed by the caller.

Leave codes

KErrUnknown

if the specified column is null; KErrNotFound if the specified column does not exist in the table.


ReadTypeAttribL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadTypeAttribL(const TDesC &aColumn, TDbColType &aColType, TUint32 &aAttrib);

Description

Gets the type and the attributes of a specific column within the current record and puts them into a TDbColType object and a reference to an unsigned integer respectively. The column is identified by the name supplied in the descriptor aColumn.

The column attributes are one or more of the values TDbCol::ENotNull and TDbCol::EAutoIncrement.

From v9.1 COMMDB_ID doesn't exist. Bacause of BC it is neccessary to return expected values

This function must not be called if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of the column in the current record whose type and attributes are to be fetched.

TDbColType &aColType

A reference to a TDbColType object passed by the caller. On successful return from this function, contains a copy of the column type.

TUint32 &aAttrib

A reference to an unsigned integer passed by the caller. On successful return from this function, contains a copy of the column attributes.

Leave codes

KErrNotFound

Specified column does not exist in the table

See also


ReadColumnLengthL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadColumnLengthL(const TDesC &aColumn, TInt &aLength);

Description

Gets the length of a specific column within the current record and copies it into a reference to an integer. The column is identified by the name supplied in the descriptor aColumn.

If the length of the column is zero and the table has a template record, then the length of the corresponding column in that template record is copied into aValue.

Null columns return 0; integers and bools return 1; strings return their length in characters.

This read operation must not occur if any of the operations involved in inserting or updating a record are still outstanding, otherwise the function raises a CommsDbServer 10 panic. For example, the panic is raised if this function is called between calls to UpdateRecord() and PutRecordChanges().

This panic is also raised if this function is called after the view has been closed.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

TInt &aLength

A reference to an integer passed by the caller. On successful return from this function, contains a copy of the length of the column.

Leave codes

KErrNotFound

Specified column does not exist in the table.


WriteTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteTextL(const TDesC &aColumn, const TDesC8 &aValue);

Description

Writes the narrow (ASCII) text from an 8 bit descriptor to a specific column within the current record. The column is identified by the name supplied in the descriptor aColumn. The length of the text cannot be greater than the value of the constant KCommsDbSvrMaxColumnNameLength, otherwise the function leaves.

An earlier call to either UpdateRecord() or InsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic. If the column identified is the COMMDB_ID field, than this function raises a CommsDbServer 13 panic.

PutRecordChanges() must be called to store the changes.

Note: If the column to be read is encrypted then the function decrypts it.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

const TDesC8 &aValue

A reference to an 8 bit descriptor containing the narrow text to be written into the column.

Leave codes

KErrOverflow

The function can leave for reasons defined by DBMS but it also leaves with KErrOverflow if the length of the text is greater than the maximum permitted.

KErrNotFound

The column name does not exist.


WriteTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteTextL(const TDesC &aColumn, const TDesC16 &aValue);

Description

Writes the wide (UNICODE) text from a 16 bit descriptor to a specific column within the current record. The column is identified by the name supplied in the descriptor aColumn. The length of the text cannot be greater than the value of the constant KCommsDbSvrMaxColumnNameLength, otherwise the function leaves.

An earlier call to either UpdateRecord() or InsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic. If the column identified is the COMMDB_ID field, than this function raises a CommsDbServer 13 panic. This panic is also raised if this function is called after the view has been closed.

PutRecordChanges() must be called to store the changes.

Note: If the column to be read is encrypted then the function decrypts it.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

const TDesC16 &aValue

A reference to a 16 bit descriptor containing the wide text to be written into the column.

Leave codes

The

function can leave for reasons defined by DBMS but also leaves with KErrOverflow if the length of the text is greater than the maximum permitted or KErrNotFound if the column name does not exist.


WriteLongTextL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteLongTextL(const TDesC &aColumn, const TDesC &aValue);

Description

Writes the long text from a descriptor to a specific column within the current record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to either UpdateRecord() or InsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic. If the column identified is the COMMDB_ID field, than this function raises a CommsDbServer 13 panic. This panic is also raised if this function is called after the view has been closed.

PutRecordChanges() must be called to store the changes.

While the text written by WriteTextL() functions is limited in length, there is no restriction on the length of long text.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

const TDesC &aValue

A reference to a descriptor containing the long text to be written into the column.

Leave codes

KErrNotFound

The column name does not exist.


WriteUintL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteUintL(const TDesC &aColumn, const TUint32 &aValue);

Description

Writes an unsigned integer value to a specific column within the current record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to either UpdateRecord() or InsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic. If the column identified is the COMMDB_ID field, than this function raises a CommsDbServer 13 panic. This panic is also raised if this function is called after the view has been closed.

PutRecordChanges() must be called to store the changes.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

const TUint32 &aValue

A reference to an unsigned integer containing the value to be written into the column.

Leave codes

KErrNotFound

The column name does not exist.

See also


WriteBoolL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void WriteBoolL(const TDesC &aColumn, const TBool &aValue);

Description

Writes a Boolean value to a specific column within the current record. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to either UpdateRecord() or InsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic. If the column identified is the COMMDB_ID field, than this function raises a CommsDbServer 13 panic. This panic is also raised if this function is called after the view has been closed.

PutRecordChanges() must be called to store the changes.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

const TBool &aValue

A reference to TBool containing the value to be written into the column.

Leave codes

KErrNotFound

The column name does not exist.

See also


SetNullL()

IMPORT_C void SetNullL(const TDesC &aColumn);

Description

Sets a specific column within the current record to NULL. For text type columns, this is the same as setting the column to an empty string. The column is identified by the name supplied in the descriptor aColumn.

An earlier call to either UpdateRecord() or InsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic. This panic is also raised if this function is called after the view has been closed.

PutRecordChanges() must be called to store the changes.

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.


ReadColumnMaxLengthL()

Capability: Dependent on table, see the guide page referenced below.

IMPORT_C void ReadColumnMaxLengthL(const TDesC &aColumn, TInt &aLength);

Description

Reads the MAXIMUM length of the contents of aColumn from the current record into aLength

Parameters

const TDesC &aColumn

A reference to a descriptor containing the name of a column in the current record.

TInt &aLength

A reference to an integer passed by the caller. On successful return from this function, contains a copy of the length of the column.


Database()

inline CCommsDatabaseBase *Database() const;

Description

Return value

CCommsDatabaseBase *


GetTableName()

inline void GetTableName(TDes &aTableName) const;

Description

Gets the name of the table associated with this view and copies it into the descriptor supplied by the caller.

Parameters

TDes &aTableName

A reference to a descriptor passed by the caller. On return from this function it contains the name of the table.

[Top]


Member data


iDb

protected: CCommsDatabaseBase & iDb;

Description


iTableName

protected: TBuf< KCommsDbSvrMaxColumnNameLength > iTableName;

Description


iTableView

protected: RDbView iTableView;

Description


iTableExt

protected: CCommDbTableExtension * iTableExt;

Description