Utility functions / List of utility functions |
Generates a new sequence for a given identifier.
DB_GET_SEQUENCE( id STRING ) RETURNING result BIGINT
This function generates a new sequence from a register table created in the current database.
CREATE TABLE seqreg ( sr_name VARCHAR(30) NOT NULL, sr_last BIGINT NOT NULL, PRIMARY KEY (sr_name) )
Each time you call this function, the sequence is incremented in the database table and returned by the function.
It is mandatory to use this function inside a transaction block, in order to generate unique sequences.
MAIN DEFINE ns BIGINT, s INTEGER DATABASE mydb BEGIN WORK LET ns = DB_GET_SEQUENCE("mytable") INSERT INTO mytable VALUES ( ns, 'a new sequence' ) COMMIT WORK END MAIN