4D v14.3Sequence number |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
Sequence number
Sequence number
Sequence number returns the next sequence number for aTable. The sequence number is unique for each table. It is a non-repeating number that is incremented for each new record created for the table. By default, the numbering starts at 1. You can change the numbering for a table using the SET DATABASE PARAMETER command. Note: If there is no current record and the numbering has been modified via the SET DATABASE PARAMETER command, this number is in fact reserved for the next record creation but it will only be returned by the Sequence number function when the SAVE RECORD command has actually been called. The Sequence number function is useful in the following cases:
To store the sequence number by means of a method, create a long integer field in the table and assign the sequence number to the field. The sequence number returned by this function for the table is the same number as the one generated when you check the Autoincrement option for a field of the table using the Structure inspector, or as the one assigned by using the #N symbol as the default value for a field of the table in a form (see the 4D Design Reference manual). Note: Automatic incrementation can also be set via the SQL AUTO_INCREMENT attribute. If the sequence number needs to start at a number other than 1, just add the difference to Sequence number. For example, if the sequence number must start at 1000, you would use the following statement to assign the number: [Table1]Seq Field :=Sequence number([Table1])+999 The following example is part of a form method. It tests to see if this is a new record; i.e., if the invoice number is an empty string. If it is a new record, the method assigns an invoice number. The invoice number is formed from two pieces of information: the sequence number, and the operator’s ID, which was entered when the database was opened. The sequence number is formatted as a 5-character string: ` If this is a new part number, create a new invoice number |
PROPERTIES
Product: 4D
HISTORY
Modified: 4D 2004.1 SEE ALSO
About Record Numbers ARTICLE USAGE
4D Language Reference ( 4D v12.4) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||