Sybase ASA sequence

70 views Asked by At

Please advice, how to get current value of sequence from system tables/views in Sybase ASA.

For example:

CREATE SEQUENCE test_seq1
INCREMENT BY 3 START WITH 5

select test_seq1.currval

Error:
The 'currval' operator is not defined yet for sequence 'test_seq1' for this connection.

I can do the following:

select test_seq1.nextval
select test_seq1.currval

but that doesn't work fo me.

Thank you!

1

There are 1 answers

0
EisenWang On

This is what sequence object in ASA do... You need to initialize it with a "select ...nextval", then it will fill the currval for you to read. BTW: the sequence object is session isolated, each session need to use its own 'select ...nextval' to initialize it then can get the currval of it.