Help Center/
Distributed Database Middleware/
User Guide (ME-Abu Dhabi Region)/
SQL Syntax/
Global Sequence/
Using NEXTVAL and CURRVAL to Query Global Sequence Numbers
Updated on 2022-12-08 GMT+08:00
Using NEXTVAL and CURRVAL to Query Global Sequence Numbers
- NEXTVAL returns the next sequence number, and CURRVAL returns the current sequence number. NEXTVAL(N) returns n unique sequence numbers.
- NEXTVAL(N) can be used only in select sequence.nextval(n) and does not support cross-schema operations.
- CURRVAL(N) is not supported.
Procedure
- Connect to the required DDM instance using a client.
- Open the required schema.
- Run the following command to create a global sequence:
create sequence seq_test;
- Run the following command to obtain the next sequence number:
select seq_test.nextval;
- Run the following command to obtain the current sequence number:
select seq_test.currval;
- Run the following command to obtain sequence numbers in batches:
select seq_test.nextval(n);
- Cross-schema operations are not supported when sequence numbers are obtained in batches.
- If no global sequence is used, CURRVAL returns 0.
Parent topic: Global Sequence
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot