## The Number Sequence Mask

This mask generates numbers in a sequence by a user-defined increment.

This mask operates on numeric (integer and real types) and text columns.

If the column is a text data type then the number generated shall be a simple integer with no formatting (e.g. no commas or other symbols to separate thousands, etc)

This mask can generate independent sequences by user-defined partitions.

You can also specify multiple Number Sequence masks so that each can operate on a separate range of rows defined by the Where condition. Each successive mask can resume the sequence from the previous Number Sequence mask or restart numbering.

You must ensure that the receiving column is large enough for the generated range of numbers otherwise a run-time error may occur. For example, if a six digit sequence number is generated but the receiving field is only a SMALLINT (maximum value of 32,767) or a VARCHAR(5) then a DBMS run-time error is likely to occur.

**Default start sequence number**

This mask will start numbering from this number *unless* Numbering 'Continue' is
selected *and* this column has another preceding Number Sequence mask that does not
use partitioning.

See 'Numbering: Continue' and 'Numbering: Start' below for more details.

This number must be an integer in the range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 inclusive.

**Increment**

The increment by which number sequence is generated.

This number must be an integer in the range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 inclusive.

**Numbering: 'Continue sequence number...'**

If there are no other Number Sequence masks prior to this one in the column's mask list then this mask's number sequence shall begin from the specified 'Default start sequence number'.

If there is a Number Sequence mask in this column prior to this mask *and* the prior
mask does *not* use a partition then this mask's number sequence shall begin at the
last number generated by the prior mask plus one (or minus one if this mask's Increment is
negative).

**Numbering: 'Start from Default start sequence number'**

The numbering shall start from the specified 'Default start sequence number'.

In this case, you have the option to specify independent number sequences for each range of rows that are defined by the same distinct values found in the specified partition columns.

For example, suppose that you wanted to generate sequence numbers, starting from 1, independently for all customers according to their city. Therefore, all customer rows that have a city of 'Melbourne' would be numbered sequentially from 1, and all rows that have a city of 'Paris' would also be numbered sequentially from 1, and so on for every other distinct value in the 'city' column.

You can specify multiple columns for the partition in which case the sequence numbers would be generated independently for all distinct values combined from each of the partition columns.

For example, if you specified the columns 'suburb' and 'postal_code' as a partition then number sequences for all rows having distinct combined values of 'suburb'+'postal_code' shall have independent number sequences generated.

**Determinism**

This mask can be deterministic or not deterministic. The setting is found in the Determinism tab.

**Deterministic**

When this mask is 'deterministic' then the sequence numbers shall be assigned to rows according to the values in the 'Order by' columns.

Note: If "Synchronize duplicates" is enabled for this column then the 'Order by' option cannot be used - an implicit 'Order by' the original values of the column being masked shall be used.

Note: This mask cannot provide true determinism because the sequence numbers generated are not explicitly determined by the value(s) in a row. In other words, if a row in a table is deleted then this may result in the remaining rows being assigned different sequence number.

Therefore, the Deterministic setting for this mask actually makes it "repeatable" (you
will get the exact same results if you repeat the masking run on *exactly* the same
input table) but not truly deterministic.

**Not Deterministic**

When this mask is not deterministic then the sequence numbers shall be assigned to rows in a random order.

**Duplicates**

This mask can preserve the duplicates property of the original data while replacing the values with the number sequence (masked data). To do this, you simply and select "Synchronize duplicates" in the Duplicates tab of the Masking window of the column being masked.

For example, if we created a Number Sequence mask starting from 100 with an increment of 1, then you can see how the duplicates property of the original data has been preserved in the masked data (shown as shaded.)

*Before:*
*After:*

Note: If "Synchronize duplicates" is used and Deterministic mode is selected, then the 'Order by' option is not available. In this case, an implicit 'Order by' the original values of the column being masked shall be used.