phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Taylor <>
Subject Re: REG: Getting the current value of a sequence
Date Sat, 22 Aug 2015 17:59:08 GMT
Hi Satya,
You can do a NEXT VALUE FOR in a SELECT clause without a from clause like

This will allocate a block of sequences from the server (as determined by
the CACHE clause when you create the sequence), cache them on the client,
and dole them out as NEXT VALUE FOR calls are made.

If you need to prefetch a guaranteed contiguous block of sequences, you may
do this:
    SELECT NEXT 1000 VALUES FOR my_seq;

This call would immediately use all 1000 values, so the next call to NEXT
VALUE FOR or NEXT VALUES FOR would start from at least 1001.


On Sat, Aug 22, 2015 at 10:27 AM, Ravi Kiran <>

> Hi Satya,
>   Unless you call NEXT VALUE FOR on a sequence *the first time*, you
> wouldn't be getting the CURRENT VALUE .   So , instead of getting the
> CURRENT VALUE, you can get the NEXT VALUE and then pass to your upsert
> query.
> Hope this helps
> On Sat, Aug 22, 2015 at 7:59 AM, Ns G <> wrote:
>> Hi All,
>> I have a requirement where the sequence number is to be prefetched and
>> then used in upsert query.
>> I know that Current Value for a sequence number gives me the last used
>> value. But It does not return value for the first time until and unless
>> used in a upsert query.
>> Is there any alternative to get the sequence immediately after
>> declaration and before using in a upsert query?
>> Thanks,
>> Satya

View raw message