User-Defined Sequences

A user-defined sequence generates unique numbers for a specific purpose. Configure the sequence through the /usersequences resource and use the code authorization_number for the authorization number sequence.

Maintain User-Defined Sequences

Send a POST request to /usersequences with the required unique sequence code:

{
  "code": "authorization_number"
}

When you omit optional settings, the sequence starts at its minimum value and increments by 1. The system returns sequence metadata through the HTTP API. To review configured sequences, send a GET request to /usersequences.

The sequence code identifies the number generator. You cannot update an existing sequence. To change its settings, delete the sequence and create it again. Before recreating a sequence, set startWith to a value that accounts for numbers already used.

Configure Sequence Settings

You can provide these optional settings when you create a sequence:

  • incrementBy: Sets the interval between sequence numbers. Specify a nonzero positive or negative integer. A positive value makes the sequence ascend; a negative value makes it descend. The value can have up to 28 digits for an ascending sequence or 27 digits for a descending sequence. Its absolute value must be less than the difference between maxValue and minValue. If you omit this setting, the interval is 1.

  • startWith: Sets the first number that the sequence generates. For an ascending sequence, the default is minValue; for a descending sequence, the default is maxValue. The value can have up to 28 digits when positive or 27 digits when negative.

  • minValue: Sets the smallest number in the sequence. The value can have up to 28 digits when positive or 27 digits when negative. It must be less than or equal to startWith and less than maxValue.

  • maxValue: Sets the largest number in the sequence. The value can have up to 28 digits when positive or 27 digits when negative. It must be greater than or equal to startWith and greater than minValue.

Use startWith to continue numbering from the latest value used in another system.

To validate a sequence, the system creates it in the Oracle database with the specified values or database defaults for omitted attributes. If the database cannot create the sequence, the system returns HTTP 422. Omitted attributes that use database defaults do not appear as values in retrieved data.

A sequence that the database creates is not necessarily usable. For example, the following setting combinations create a sequence, but requesting its next number raises the listed database error:

Table 1. Sequence settings that cannot generate a number
incrementBy startWith minValue maxValue Database Error

-2

-1

0

100

ORA-08004: sequence OHI_UDS_SEQ1.NEXTVAL goes below MINVALUE and cannot be instantiated

2

20

10

18

ORA-08004: sequence OHI_UDS_SEQ2.NEXTVAL exceeds MAXVALUE and cannot be instantiated

Sequence Ordering in RAC Deployments

In an active-passive RAC deployment, the system guarantees the order of sequence generation. In an active-active RAC deployment, sequence generation is unordered.