System and External Tables
Certain tables should be connected to the data-server structure for which you have no reason to create a Data Dictionary object. A prime example is a system table containing a counter either for census purposes or for the purpose of assigning unique identification keys. Such tables must be registered in the Data Dictionary as an external table.
Any Data Dictionary code you write that updates a non-related table during a transaction (i.e., when the DDO is locking tables and records) should be added to the Data Dictionary class’s list of external tables. Failure to do this will raise locking errors when your code tries to commit a save to the external file.
External Tables are declared within a Data Dictionary class using the Add_System_File message.
Set Add_System_File to Ordsys.File_Number DD_LOCK_ON_NEW_SAVE_DELETE
If an External Table is used, it will probably be used within one or more of the following events: Update, Backout, Creating, Deleting, Validate_Save, and Validate_Delete. If you refer to an external table in these events, you will want to add this table to the external table list.
If you are using the Field_Auto_Increment method to define an auto-increment field and the table used to provide the auto-increment number is a system table, that table must be added to the external table list.
Set Add_System_File to Ordsys.File_Number DD_LOCK_ON_NEW_SAVE_DELETE
Set Field_Auto_Increment field Customer.cust_number to file_field ordsys.last_cust_num
Often, system tables are not assigned a DDO. System tables represent the one exception to the Framework rule that states that a Data Dictionary subclass should be created and used for every table in an application.
Because system tables contain just one record and that record may be used by many users, an additional optimization parameter is added to determine when the external table is locked. This parameter has the following values:
- DD_Lock_On_All: Lock on all saves and deletes
- DD_Lock_On_New_Save_Delete: Lock on new saves and deletes
- DD_Lock_On_Save: Lock on all saves
- DD_Lock_On_New_Save: Lock only on new saves
- DD_Lock_On_Delete: Lock only on deletes
For system tables supporting unique ID serial numbers, DD_Lock_On_New_Save should be sufficient; for tables supporting counters that increment and decrement, the other two modes would be required, so DD_Lock_On_All would be appropriate.
Note that this locking optimization is only applied to the DataFlex Embedded Database.