Field_Auto_Increment - DataDictionary

Defines a column's auto-increment table and column

Type: Property

Access: Write-Only

Data Type: Integer

Parameters: Integer iField Integer iSysFile

ParameterDescription
iFieldNumber of the column in the table
iSysFileTable number of the system table used as the counter source


Syntax
 Property Integer Field_Auto_Increment

Write Access: Set Field_Auto_Increment iField iSysFile to IntegerVariable/Value


Description

The Field_Auto_Increment property defines the external table and column (ExternalTable.ExternalColumn) to auto-increment a Data Dictionary table and column from.

Set Field_Auto_Increment Field Customer.Customer_Number to File_Field Ordsys.Customer_Number

This uses an unusual syntax where the File_Field syntax is used on the right side of the "to" token. This syntax is managed by the Studio's Visual DataDictionary Modeler. You may also place two integer parameters to the right of the "to" token although this syntax is not modeled and therefore should not be used for normal column definitions.

Procedure RemoveAutoIncrement 
    Set Field_Auto_Increment Field Customer.Customer_Number to 0 0
End_Procedure

Field_Auto_Increment allows you define (in a DataDictionary class) which external table and column a table and column should be used as the counter to auto-increment a column from. The auto-increment will occur during the saving of a new record. This is typically used to generate unique numeric identifiers for records in a table from a system table (a table with a single record), but could also be used to increment counters for line item records from a header record (e.g. classic order header-line item scenario).

The ExternalTable.ExternalColumn must be a numeric integer column and should be defined with a large enough length to allow creation of as many records as needed. For example, for a table that will never contain more than 99 records, the ExternalTable.ExternalColumn does not need to be able to hold a number higher than 99.

If the ExternalTable.ExternalColumn column is in a table that is not a relational ancestor of the table being incremented, the table must be defined in the DataDictionary class as an external table and how and when the table should be locked (e.g. when saving a new record). This is done using the Set Add_System_File message.

You will normally only assign one oor no auto increment columns per DDO. You are, however, allowed to assign multiple auto increment columns for a single DDO. This is considered unusual.

Note that this method is a write only procedure. A function also named Field_Auto_Increment is used to return a column's auto-increment table and column.

Integer iAutoColumn iAutoTable 
// note use of byref value to return the auto-increment column
Get Field_Auto_Increment File_Field Customer.Customer_Number (&iAutoColumn) to iAutoTable


Using an Identity Colum

If you are using an SQL based database and Connectivity Kit, you can use an identity column instead of Field_Auto_Increment. This has the advantage that there is no locking contention on a system table and requiring no programming code.

Alternate (obsolete) Syntax

Prior to version 14.1, the command Define_Auto_Increment was used to define a column's auto-increment source.The alternate syntax is now obsolete, but it is still supported for compatibility reasons. This old syntax cannot be modeled and only allows you to create a single auto-increment column per table.

See Also

Add_System_File