phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ns G <nsgns...@gmail.com>
Subject Re: REG: Getting the current value of a sequence
Date Sun, 23 Aug 2015 00:41:40 GMT
Thank you James and Ravi. This has helped

Satya
On 22-Aug-2015 11:29 pm, "James Taylor" <jamestaylor@apache.org> wrote:

> Hi Satya,
> You can do a NEXT VALUE FOR in a SELECT clause without a from clause like
> this:
>     SELECT NEXT VALUE FOR my_seq;
>
> 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.
>
> Thanks,
> James
>
>
>
> On Sat, Aug 22, 2015 at 10:27 AM, Ravi Kiran <maghamravikiran@gmail.com>
> wrote:
>
>> 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 <nsgnsg84@gmail.com> 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
>>>
>>
>>
>

Mime
View raw message