Function DbInfo() Foundation

Sets or returns information about a work area (database object).

Syntax
DbInfo( <nDefine>, [<xNewSetting>] ) --> xOldSetting
Parameters
<nDefine>
For the parameter <nDefine>, a #define constant must be used from an #include file. This determines the setting selected for the current database object. The file DMLB.CH contains the constants valid for any database object. Depending on the database engine used to produce a database object, other specific constants can also be set. For DBF files, the specific constants are contained in the file DBFDBE.CH. In this case, the constants for <nDefine> must begin with the prefix DBFDBO_.
<xNewSetting>
For the settings of a database object that can be changed, the setting specified with <nDefine> is replaced by the value <xNewSetting>.
Return

The return value of DbInfo() is the value for the setting specified by <nDefine> in the database object. If it is a changeable setting and <xNewSetting> was specified, the function returns the old value.

Description

When a file is opened in a work area using the command USE or the function DbUseArea(), an instance of the current database engine (DBE) is automatically created. This is a database object (DBO) which manages the open file. The DBO also contains information about the file open in the work area (a DBO represents the work area).

The function DbInfo() allows the current value of settings to be read or new values assigned and is only valid for a work area in which a file is opened. If no file is open in the work area where DbInfo() is executed, a runtime error occurs. The available and changeable settings are dependent on the DBE from which produced the DBO. Use the following links to get more information about the configuration of the various DBEs:

No-SQL Database Engines:

- DBF Database Engine

- FOX Database Engine

Client/Server Database Engines:

- Postgres Database Engine

- ADS Database Engine

- ODBC Database Engine

Information about individual fields in a work area can be obtained using the function FieldInfo().

Examples
Get information about a work area with DbInfo()

// In the example, a database file is opened and then various 
// #define constants are passed to DbInfo(). The return 
// value of the function DbInfo() depends on the #define 
// constant. 

#include "DbfDbe.ch" 

PROCEDURE Main 

   USE Customer ALIAS Cust 
   SET INDEX TO CustA, CustB, CustC 

   ? DbInfo( DBO_ALIAS )         // result: Cust 
   ? DbInfo( DBO_FILENAME )      // result: 
                                 //    c:\xpp\samples\data\misc\customer.dbf 

                                 // file handles 
   ? DbInfo( DBFDBO_DBFHANDLE )  // result: 8 (= DBF file) 
   ? DbInfo( DBFDBO_DBTHANDLE )  // result: 9 (= DBT file) 

                                 // number of available orders 
   ? DbInfo( DBO_ORDERS )        // result: 3 

   USE 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.