javasqlsequencederby

How to use SEQUENCE in Apache Derby?


I'd like to use SEQUENCE support in Apache Derby 10.7. I've created the sequence with the following statement:

CREATE SEQUENCE SAMPLE_SEQ AS INT MAXVALUE 999999 CYCLE;

How can I select next/current value from the SAMPLE_SEQ? Could you please help me out with the query?


Solution

  • Apache Derby Doc says: Use a NEXT VALUE FOR expression

    Should be something like

    SELECT NEXT VALUE FOR SAMPLE_SEQ;