Opening a table

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Opening a table

Return to chapter overview

You can open a table by calling DbiOpenTable, and passing appropriate parameters such as table name, driver type, index, type of access, and share mode. After the table is successfully opened, BDE returns a cursor handle to the table.

Specifying the table name and driver type

If the application supplies the fully qualified table name of a Paradox or dBASE table, it need not specify the driver type parameter. The driver type is determined from the table name extension. If the table name does not include a path, the path name defaults to that of the current directory of the database associated with the database handle.

Driver type must be specified if the table name has no extension, or to overwrite the default driver associated with the file extension, or to terminate the table name with a period(.). If the table name does not supply the default extension, and driver type parameter is NULL, DbiOpenTable attempts to open the table with the default file extension designated for each file-based driver listed in the configuration file, in the order that the drivers are listed.

The driver types and their default extensions for Paradox, dBASE, and Text drivers are listed below:

Driver Type

Default Extension

PARADOX

.DB

dBASE

.DBF

ASCIIDRV

.TXT

For SQL databases, the table name can be a fully qualified name that includes the owner name, in the form

<owner>.<tablename>

If not specified, <owner> is inferred from the database handle. Driver type is ignored if the database is a SQL database, since driver binding is done when the database is opened.

For Access databases, a driver type and table identifier are required.

Specifying an index

To open a table with an active index, you can use the following parameters, depending on the type of table being opened: pszIndexName, pszIndexTagName, or iIndexId. The active index determines the order of records for this cursor.

Paradox: If all index parameters are NULL, the table is opened in primary key order, if a primary key exists. If a secondary key is specified, the table is opened on that key. Either pszIndexName or iIndexID can be used to specify a composite or non-composite secondary index.

Access: If all index parameters are NULL, the table is opened in natural order. Either pszIndexName or iIndexID can be used to specify a composite or non-composite secondary index.

dBASE and FoxPro: If no index is specified, the table is opened in physical order.

_bm0        Use the pszIndexName parameter in the form <tablename>.MDX or <tablename>.CDX if the index is within a production index.
_bm0        Use the pszIndexTagName parameter to specify the tag name of the index in an MDX or CDX file. This parameter is ignored if the index given by pszIndexName is an NDX index.

SQL: Use the pszIndexName parameter to specify the index name. The index name can be qualified or unqualified. An unqualified index name succeeds only if the owner of the index is the current user. (For servers supporting naming conventions with owner qualification, it is not necessary to qualify the index name with the owner.)

Specifying table open mode

A table can be opened in EXCLUSIVE or SHARED mode. When a table is opened in exclusive mode, no other user can access the table. When a table is opened in share mode, other users can access the table at the same time.

Specifying the data translation mode

The xltFIELD translation mode is recommended. This mode ensures that BDE automatically translates data from the database's native physical data format to the common BDE logical data format when a field is read from the record buffer. BDE translates the data back into native format when the field is written to the record buffer.

When the translation mode is xltNONE, no data translation takes place when a field is read from the record buffer, or when a field is written to the record buffer.

Note:Data translation occurs only during calls to DbiGetField and DbiPutField; not when the record is read.

 

 Preparing to access a table%!AL(`preparingtoaccess')

 Accessing and updating tables%!AL(`accessingtables')