Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: commdb.h
Link against: commdb.lib

Class CCommsDbTableView

CCommsDbTableView

Support

Supported from 5.0

Description

The view on a specific table.

It includes the necessary behaviour for navigating through the records in the view as well containing member functions for reading and writing to columns within a record.

An object of this type cannot be explicitly constructed; it is always constructed, and a pointer to it returned, as a result of a call to one of the following member functions of the CCommsDatabase class:

Derivation

CBaseBase class for all classes to be instantiated on the heap
CCommsDbTableViewThe view on a specific table

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

Inherited from CBase:
operator new()


Destruction


~CCommsDbTableView()

~CCommsDbTableView();

Description

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

[Top]


Navigating records in the view


GotoFirstRecord()

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.

Notes:

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

The CommsDbServer 6 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 view is empty and has no records, otherwise another of the system-wide error codes.


GotoNextRecord()

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.

Notes:

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.


GotoPreviousRecord()

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.

Notes:

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.

[Top]


Making changes to records


InsertRecord()

TInt InsertRecord(TUint32& aId);

Description

Prepares database to insert a new record — must be called before writing to any column.

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

The function puts the unique Id associated with this new record in aId.

Notes:

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

A reference to an unsigned integer passed by the caller. On successful return from this function, contains the unique Id associated with this new record.

Return value

TInt

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

Leave codes

 

The function leaves with KErrOverflow , if the table is either the modem preferences table or the connected modem table and a record already exists.


UpdateRecord()

TInt UpdateRecord();

Description

Prepares to update the current record — must be called before writing to any column.

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

Notes:

Return value

TInt

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


DeleteRecord()

TInt DeleteRecord();

Description

Deletes the record at the current cursor position.

Note:

Return value

TInt

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


PutRecordChanges()

TInt PutRecordChanges(TBool aHidden=EFalse);

Support

Withdrawn in 6.0

Description

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

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

Note:

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.

Return value

TInt

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


PutRecordChanges()

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

Support

Supported from 6.0

Description

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

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

Note:

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.


CancelRecordChanges()

void CancelRecordChanges();

Support

Supported from 6.0

Description

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

Note:

A call to one of eitherInsertRecord()orUpdateRecord() must have previously been made otherwise the function raises a CommsDbServer 5 panic.


CancelRecordChanges()

TInt CancelRecordChanges();

Support

Withdrawn in 6.0

Description

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

Note:

A call to one of eitherInsertRecord()orUpdateRecord() must have previously been made otherwise the function raises a CommsDbServer 5 panic.

Return value

TInt

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

[Top]


Reading data from a column


ReadTypeAttribL()

void ReadTypeAttrib(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 type is described by the TDbColType enumerator defined in d32dbms.h.

The column attributes are one or more of the valuesTDbCol::ENotNull andTDbCol::EAutoIncrementdefined in d32dbms.h.

Notes:

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

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

KErrCorrupt

Incorrect column type specified

KErrNotFound

Specified column does not exist in the table


ReadUintL()

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 descriptoraColumn.

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 intoaValue.

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

Notes:

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

KErrCorrupt

Incorrect column type specified

KErrUnknown

Specified column is null

KErrNotFound

Specified column does not exist in the table


ReadBoolL()

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.

Notes:

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

KErrCorrupt

Incorrect column type specified

KErrUnknown

Specified column is null

KErrNotFound

Specified column does not exist in the table


ReadTextL()

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 descriptoraValue 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 defined in cdblen.h. The maximum length of aValue supplied by the caller can, therefore, be the same.

Notes:

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

KErrCorrupt

Incorrect column type specified

KErrNotFound

Specified column does not exist in the table


ReadTextL()

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 descriptoraValue 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 defined in cdblen.h. The maximum length of aValue supplied by the caller can, therefore, be the same.

Notes:

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

KErrCorrupt

Incorrect column type specified

KErrNotFound

Specified column does not exist in the table


ReadColumnLengthL()

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.

Notes:

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


ReadLongTextLC()

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 theReadTextL()functions is limited in length, there is no restriction on the length of long text.

Notes:

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

KErrCorrupt

Incorrect column type specified

KErrNotFound

Specified column does not exist in the table

[Top]


Writing data to a column


WriteUintL()

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 descriptoraColumn.

An earlier call to eitherUpdateRecord()orInsertRecord() 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.

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

 

The function can leave for reasons defined by DBMS.


WriteBoolL()

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 descriptoraColumn.

An earlier call to eitherUpdateRecord()orInsertRecord() 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.

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

 

The function can leave for reasons defined by DBMS.


WriteTextL()

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 constantKCommsDbSvrMaxColumnNameLength defined in cdblen.h, otherwise the function leaves.

An earlier call to eitherUpdateRecord()orInsertRecord() must have been made before calling this function otherwise the function raises a CommsDbServer 12 panic.

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

 

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.


WriteTextL()

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 constantKCommsDbSvrMaxColumnNameLength defined in cdblen.h, otherwise the function leaves.

An earlier call to eitherUpdateRecord()orInsertRecord() 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.

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 it also leaves with KErrOverflow , if the length of the text is greater than the maximum permitted.


WriteLongTextL()

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 descriptoraColumn.

An earlier call to eitherUpdateRecord()orInsertRecord() 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.

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

 

The function can leave for reasons defined by DBMS.


SetNullL()

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 descriptoraColumn.

An earlier call to eitherUpdateRecord()orInsertRecord() 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.

Parameters

const TDesC& aColumn

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

[Top]


Get name of the table


GetTableName()

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.