Sequence number

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 2004.1 (Modified)


Sequence number {(aTable)} Number

ParameterTypeDescription
aTableTableTable for which to return the sequence number, or
Default table, if omitted
Function resultNumberSequence number

Description

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.

You should use the Sequence number function instead of the #N symbol if:

You are creating records procedurally

The sequence number needs to start at a number other than 1

The sequence number needs an increment greater than 1

The sequence number is part of a code, for example a part number code

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 is the same number assigned by using the #N symbol as the default value for a field in a form. For information on assigning default values, see the 4D Design Reference manual.

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

Example

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
   If ([Invoices]Invoice No = "")
         ` The invoice number is a string that ends with the operator's ID. 
      [Invoices]Invoice No:=String(Sequence number;"00000")+[Invoices]OpID 
   End if

See Also

About Record Numbers, Record number, Selected record number.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next