Search
ctrl+/
Ask AI
ctrl+.
Light
Dark
System
Sign in

Sequences​

sequence

Auto-incrementing sequence of int64.

sequence_next()

Increments the given sequence to its next value and returns that value.

sequence_reset()

Resets a sequence to initial state or a given value, returning the value.

type

sequence
sequence

An auto-incrementing sequence of int64.

This type can be used to create auto-incrementing properties:

Copy
scalar type TicketNo extending sequence;

type Ticket {
    number: TicketNo {
        constraint exclusive;
    }
}

A sequence is bound to the scalar type, not to the property, so if multiple properties use the same sequence, they will share the same counter. For each distinct counter, a separate scalar type that is extending sequence should be used.

function

sequence_next()
std::sequence_next(seq: schema::ScalarType) -> int64

Increments the given sequence to its next value and returns that value.

See the note on specifying your sequence for best practices on supplying the seq parameter.

Sequence advancement is done atomically; each concurrent session and transaction will receive a distinct sequence value.

Copy
db> 
select sequence_next(introspect MySequence);
{11}

function

sequence_reset()
std::sequence_reset(seq: schema::ScalarType) -> int64std::sequence_reset( seq: schema::ScalarType, val: int64) -> int64

Resets a sequence to initial state or a given value, returning the value.

See the note on specifying your sequence for best practices on supplying the seq parameter.

The single-parameter form resets the sequence to its initial state, where the next sequence_next() call will return the first value in sequence. The two-parameter form allows you to set the current value of the sequence. The next sequence_next() call will return the value after the one you passed to sequence_reset().

Copy
db> 
select sequence_reset(introspect MySequence);
{1}
Copy
db> 
select sequence_next(introspect MySequence);
{1}
Copy
db> 
select