The function sets and returns the state of a sequence object. The mode specifies whether a check for order of values should be made. If mode equals 0, the state is set regardless of the previous state. If mode is non-zero, the state is changed only if the new state is greater than the previous state. This gives some (weak) protection from occasional 'rewind' the sequence back to values that are already in use.
The function returns an integer that is equal to what the next call to sequence_next() will return.
The sequence of calls demonstrates various calls of sequence_set().
select sequence_set ('sample', 5, 0); 5 1 Rows. -- 0 msec. select sequence_next ('sample'); 5 1 Rows. -- 0 msec. select sequence_next ('sample'); 6 1 Rows. -- 0 msec. -- This has no effect because current state(6) is greater than 2. select sequence_set ('sample', 2, 1); 7 1 Rows. -- 0 msec. select sequence_next ('sample'); 7 1 Rows. -- 0 msec. -- But this change has effect: select sequence_set ('sample', 2, 0); 2 1 Rows. -- 0 msec. select sequence_next ('sample'); 2 1 Rows. -- 0 msec.