Skip to content

Define_Auto_Increment

Obsolete

As of version 14.1, the Define_Auto_Increment command is obsolete and has been replaced with the Field_Auto_Increment property in the DataDictionary class. This command and the following documentation exist for compatibility reasons only.

See Also

Purpose

Define the external table and column to auto-increment a Data Dictionary table and column from.

Syntax

Define_Auto_Increment {ExternalTable}.{ExternalColumn} to {CurrentTable}.{CurrentColumn}

Where {ExternalTable} and {ExternalColumn} are the external table and column to use as the auto-increment counter, and {CurrentTable}.{CurrentColumn} are the table and column to auto-increment.

What It Does

Define_Auto_Increment allows you to define (in a DataDictionary class) which external table and column a table and column should use 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} is in a table that is not a relational ancestor of the table being incremented ({CurrentTable}), 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 Add_System_File message.

Example

The following example shows how to define that Ordsys.Last_Cust_Num should be used as the auto-increment counter column for Customer.Cust_Number.

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

Notes

  • 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 do this by adding custom code to the Data Dictionary Creating event.