Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the Sequence number command with existing data
Published On: January 17, 2007

The Sequence number command increments only on creation of, and successful save thereof, a new record. It does not increment the value upon calling the command when saving an existing record.

This issue comes up when using the Sequence number command with existing data. If there are already records that have been created in your table the sequence number will already be set to whatever would be the value for the next record. If you need to assign this as a value to your old records it must be done manually, rather than using Sequence number to assign values.

For example say you add a new Alpha field to a table with 500 records and you want to store a non repeating number in the new field. In order to use Sequence number you must first manually assign a value to the 500 existing records. You can then use Sequence number for all new records in order to ensure you get non-repeating values in that field.

Also note that you can use the SET DATABASE PARAMETER command to change the next value that will be returned by sequence number. Following the above example, say you want the next sequence number to be 50001 instead of 501. You would call SET DATABASE PARAMETER as follows:

SET DATABASE PARAMETER([Table name]; 31; 50001)

For more information on the Sequence number command see:

For more information on the SET DATABASE PARAMETER command see: