1C:Enterprise 8.3. Developer Guide. Appendix 8. Work in Xbase

1C:Enterprise 8.3. Developer Guide. Contents


WORK IN XBASE

This section explains the terms used to describe XBase object – 1C:Enterprise script tool that helps operate databases.

8.1. FIELDS AND RECORDS

A telephone directory for a company is a good example of a database. It contains last names, telephone numbers and room numbers for all the employees of the company. Each line of the telephone book is a record and each column is a field. Each field has a name and attributes of information that is stored in it: type, length and precision. Field contents for a specific record is called field value. For example, a telephone book can be organized as a table with columns (fields) Full name, Room number and Phone. Each row (record) contains information about one employee.

8.2. SPREADSHEET, SPREADSHEET STRUCTURE AND DATABASE FILE

In the database context, the entire telephone book is called a spreadsheet. Spreadsheet fields determine spreadsheet structure and spreadsheet records determine spreadsheet contents. Each record in the table contains the same set of fields as the entire spreadsheet. Therefore this set is sometimes referred to as record structure. Record structure is basically the same as spreadsheet structure, although the former term is more accurate since a spreadsheet always has a structure even if it does not contain any records.

Implementation of databases in the DBF format implies that each spreadsheet is stored in a separate file. Therefore, hereinafter we shall refer to a database spreadsheet file as a database file or DB file.

8.3. INDICES, INDEX AND FILTER EXPRESSIONS AND INDEX FILE

An index system is used to organize database file contents and to search for values of one or more fields. It has the same principle as sorting a card register based on a certain attribute (a set of attributes). However, unlike a card register, a DB file can contain several indices and its contents can be sorted by several attributes. Each index has a name, unique attribute, expression and filter. The index name is used for identification purposes. The index expression and filter are expressions written in a special language. When values of these expressions are calculated for each record, the results are used to determine its location and the necessity for placing it into an ordered list (an index can contain information not about all spreadsheet records, but only about those that meet the requirements of the filter expression). A unique index (that has the unique attribute on) can contain only references to records with different index expression values.

Indices are stored in an index file. The index file can contain information about more than one index.

8.4. WRITING CHANGES TO DATABASE

Each object is a data structure located in the computer memory. When you change object properties, database files are not immediately modified. When the auto-save mode is on, object changes are written to the database only when you change the position (move to the next record, perform a key search, etc). When the auto-save mode is off, changes are written only when you run the appropriate object method.

8.5. WORK WITH INDEX FILES

Please keep in mind that XBase can be linked only to one index file at once. All database changes made during a session with one index file do not influence other index files. Therefore, it is not recommended to use more than one index file for a database. Otherwise index file contents have to be updated every time a database with a new index is opened.

8.6. RECORD DELETION

Deleting database record does not physically erase it on disk. If you delete records, a special deletion mark is put into a hidden system field that cannot be accessed in the usual way. You cannot switch to records that are marked as deleted unless you are running a special mode of viewing deleted records. There is a property that manages this special mode and there are several methods that are used to determine whether the current record is deleted and to restore the deleted records.

The database compression method physically erases the database records that are marked as deleted. The database clear method physically erases all database records. After any of these methods has been used, deleted records cannot be restored in future.

8.7. CREATION OF DATABASE, INDEX AND INDEX FILE

In addition to methods for working with existing databases, XBase objects have methods for creating new databases of an arbitrary structure, new indices and new index files. Please note that although you can use methods that change the database structure only for objects that are not linked to the existing database (i.e. for new databases), you can create new indices and index files both for new and existing databases.

8.8. LIMITATIONS

The main purpose of XBase objects is organizing information export/import to/ from external files in DBF format.

XBase objects do not support memo-type fields. XBase objects support only exclusive access to files. XBase objects support index files in CDX format. However, it is not recommended to use index files created with XBase in external programs (e.g., FoxBase) and it is not recommended to use index files created with external programs in XBase objects due to possible incompatibility of versions.

Leave a Reply

Your email address will not be published. Required fields are marked *

1C:Enterprise Developer's Community