Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: d32dbms.h
Link against: edbms.lib

Class RDbTable

RDbTable

Support

Supported from 5.0

Description

Provides access to table data as a rowset, allowing manipulation of a named table in the database. Additionally, a named index can be used to order the rowset, and to provide fast key-based row retrieval from the table.

There are no special rules to consider when deriving from this class.

Derivation

RDbRowSetAn abstract base class that provides functionality which is shared between SQL view objects and Table objects
RDbTableProvides access to table data as a rowset, allowing manipulation of a named table in the database

Defined in RDbTable:
EEqualTo, EGreaterEqual, EGreaterThan, ELessEqual, ELessThan, Open(), SeekL(), SetIndex(), SetNoIndex(), TComparison

Inherited from RDbRowSet:
AtBeginning(), AtEnd(), AtRow(), BeginningL(), Bookmark(), Cancel(), Close(), ColCount(), ColDef(), ColDes(), ColDes16(), ColDes8(), ColInt(), ColInt16(), ColInt32(), ColInt64(), ColInt8(), ColLength(), ColReal(), ColReal32(), ColReal64(), ColSetL(), ColSize(), ColTime(), ColType(), ColUint(), ColUint16(), ColUint32(), ColUint8(), CountL(), DeleteL(), EBackwards, EBeginning, EEnd, EEnsure, EFirst, EForwards, EInsertOnly, ELast, ENext, EPrevious, EQuick, EReadOnly, EUpdatable, EndL(), FindL(), FirstL(), GetL(), GotoL(), InsertCopyL(), InsertL(), IsColNull(), IsEmptyL(), LastL(), MatchL(), NextL(), PreviousL(), PutL(), Reset(), SetColL(), SetColNullL(), TAccess, TAccuracy, TDirection, TPosition, UpdateL()


Opening a table


Open()

TInt Open(RDbDatabase& aDatabase,const TDesC& aName,TAccess anAccess=EUpdatable);

Description

Opens the named table object on a database with the specified access.

If successful, the rowset is positioned to the beginning.

Parameters

RDbDatabase& aDatabase

The database on which to open the table.

const TDesC& aName

The name of the table to open.

TAccess anAccess

The access specification for the rowset, the default is updatable access.

Return value

TInt

KErrNone, if successful, otherwise one of the system-wide error codes. Specifically:KErrNotFound if the table does not exist in the database.KErrAccessDenied if an incremental operation is in progress. This can also be one of the DBMS database error codes.

See also:

[Top]


Setting the row order


SetIndex()

TInt SetIndex(const TDesC& anIndex);

Description

Sets the specified index as the active index for this table. The rows will be presented in index order, and this index key will be used for lookup by the SeekL() function.

If successful, the rowset is reset to the beginning.

Parameters

const TDesC& anIndex

The name of the index to activate.

Return value

TInt

KErrNone, if successful, otherwise one of the system-wide error codes. Specifically:KErrWrite if the table was created with insert-only access.KErrNotFound if the index does not exist on the table. This can also be one of the DBMS database error codes.

See also:


SetNoIndex()

TInt SetNoIndex();

Description

Sets the ordering to be the underlying ordering of the rows — this will usually provide faster navigation of the rowset.

Return value

TInt

KErrNone, if successful, otherwise one of the system-wide error codes. Specifically:KErrWrite if the table was created with insert-only access. This can also be one of the DBMS database error codes.

See also:

[Top]


Key-based row lookup


SeekL()

TBool SeekL(const TDbSeekKey& aKey,TComparison aComparison=EEqualTo);

Description

Finds a row in a table based on a key in the active index.

This function cannot be called while the rowset is currently updating or inserting a row. The currently active index on the table must have a key definition which matches the types in the key value.

Less columns can be added to the key than are present in the index definition: the keys will only be compared up to the columns present — further columns in the index are not considered.

If successful the cursor is positioned to the row which was found, otherwise the cursor is left on an invalid row.

The underlying Store database can leave with KErrWrite, if the table was created with insert-only access.

The function can also leave with one of the DBMS database error codes.

Parameters

const TDbSeekKey& aKey

The key value to lookup in the index.

TComparison aComparison

The comparison operation for the lookup, the default is to look for an exact match (EEqualTo).

Return value

TBool

True if a row which compares correctly with the key exists, false if not.

See also:

[Top]


Enumerations


Enum TComparison

TComparison

Description

Database table seek comparison types.

ELessThan

Retrieve the last row which is strictly less than the key value.

ELessEqual

Retrieve the last row which is equal to or less than the key value.

EEqualTo

Retrieve the first row which is equal to the key value.

EGreaterEqual

Retrieve the first row which is equal to or greater than the key value.

EGreaterThan

Retrieve the first row which is strictly greater than the key value.