Add_System_File - DataDictionary

Obsolete Adds iFile to this object's system file list

Type: Procedure

Parameters: integer iFile integer iLock_Mode

ParameterDescription
iFleNumber of the table to add to this object's system (externally locked) filelist
iLock_ModeThis parameter affects the events during which locks will affect table iFile. Can be one of the following constant values:

ConstantMeaning
DD_Lock_On_AllLock on all saves and deletes (default)
DD_Lock_On_New_Save_DeleteLock on new saves and deletes
DD_Lock_On_SaveLock on all saves
DD_Lock_On_New_SaveLock only on new saves
DD_Lock_On_DeleteLock only on deletes


Syntax
Procedure Add_System_File integer iFile integer iLock_Mode

Call: Send Add_System_File iFile iLock_Mode


Description

Obsolete

Note: As of version 14.1, the Send Add_System_File is obsolete and has been replaced with the Set Add_System_File message. This message and the following documentation exists for compatibility reasons only.


Send Add_System_File  OrdSys.File_Number DD_Lock_On_New_Save_Delete


Each record in a Table should contain a field or set of fields that provides the record a unique ID. This will usually be your Primary key. In some cases, the value of the primary key must be manually provided by the operator (e.g. entering a unique string ID as part of data input). In some cases, the back-end database will provide the primary key automatically when the record is saved. In other cases, the Data Dictionary must to provide the unique ID when the record is first saved.

The auto-increment feature of the Data Dictionary provides this facility by automatically assigning unique sequential numbers for each new record.

In order for the Data Dictionary to know what next increment value will be for a new record, it must store the last assigned number in some other external table. To create an auto-increment field, you will need to define the table and field of the external table as well as the ID field in your Data Dictionary. A special command, Define_Auto_Increment, is provided to do this:

Define_Auto_Increment ordsys.last_cust_num to Customer.cust_number

In this example, the field last _cust_num in the system table ordsys is designated to increment and provide a value to the field cust_number in the Table Customer.

Auto incrementing will only work correctly if the external table is a (one record) system table or is a related parent table.

You will use a system table if the unique ID is single segment as is shown in the above example with cust_number. If you are using a field from a system table, you need to register this table as an external table so that it will be correctly locked during save operations. For example:

Define_Auto_Increment OrdSys.Last_Cust_Num to Customer.cust_number
Send Add_System_File  OrdSys.File_Number DD_Lock_On_New_Save_Delete


You may use a related parent table if your unique ID is multi-segment. For example, an order-detail ID may consist of an Order Number (OrderDtl.Order_number) and a system assigned detail number (OrderDtl.Detail_Number). If the last detail number was stored in each Order within the Order header table (OrderHea.Last_Detail_Num) the auto increment field would be defined as:

Define_Auto_Increment OrderHea.Last_Detail_Num to OrderDtl.Detail_Number


You may only assign one auto increment field per DDO. If you attempt to assign two, then the first field's auto-increment setting will be erased. If you need to assign additional auto-increment fields within your Data Dictionary you may easily do this by adding custom code to the Data Dictionary Creating event.

See Also

System_File_Count | System_File_Number | System_File_Lock_Mode | Defining Data Dictionary Field Attributes System and External Tables