# 22. Virtuoso Functions Guide - sequence_set

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
__any_grants
close
collation_define
complete_table_name
delay
end_result
exec
exec_next
exec_result
exec_result_names
identity_value
name_part
registry_get
registry_get_all
registry_name_is_pro...
registry_remove
registry_set
result
result_names
row_count
sequence_get_all
sequence_next
sequence_remove
sequence_set
set_identity_column
set_row_count
set_user_id
signal
sinv_create_inverse
sinv_create_key_mapp...
sinv_drop_inverse
sys_stat_analyze
sys_stat_histogram
table_drop_policy
table_set_policy
username
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY
Functions Index

## sequence_set

Sets and returns the state of a sequence object.
integer sequence_set (in name varchar, in state integer, in mode integer);
Description

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.

Parameters
name – The server-wide name of a sequence.
state – A new state of the sequence.
mode – Flags if a new state of the sequence should be ignored if it is less than the current one.
Return Types

The function returns an integer that is equal to what the next call to sequence_next() will return.

Examples
Different modes of sequence_set()

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.

See Also

Sequence Objects

sequence_get_all

sequence_next

sequence_remove

registry_get

registry_get_all

registry_set

registry_name_is_protected

registry_remove