Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Andrew Grantham (Informix 10.00.FC10, Solaris) asked how to read a sequence's current value without changing it, since dbschema and currval/nextval alter it. Marcus Haarmann and Art Kagel said there is no way; even dbschema increments it. Ajay Gupta offered a query joining syssequences, systables and sysmaster:sysptnhdr (cur_serial8), which works only when the sequence cache size is 1.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
All,
Informix 10.00.FC10
Sun Solaris
All,
Can someone tell me how I can determine the current sequence number for a
sequence from the system tables or by using a command that does not affect the
resulting value? Seemingly using dbschema or the select currval, nextval has
an affect on the value returned.
Regards
Andy Grantham
Hi,
I have been searching for that a while ago, but even dbschema does a nextval
internally.
And the value is not stored in any systable which I know of.
Also, all answers from this list I have searched were negative. So, from my
point of view
no way to retrieve the actual sequence value without incrementing the sequence.
Does not really depend on the version (at least in 9.4, 10.0, 11.10, 11.50,
11.70 I found no clue).
Marcus Haarmann
----- Ursprüngliche Mail -----
Von: "Andrew Grantham" <agrantha@hotmail.com>
An: ids@iiug.org
Gesendet: Mittwoch, 5. März 2014 10:59:13
Betreff: question about sequences [32644]
All,
Informix 10.00.FC10
Sun Solaris
All,
Can someone tell me how I can determine the current sequence number for a
sequence from the system tables or by using a command that does not affect the
resulting value? Seemingly using dbschema or the select currval, nextval has
an affect on the value returned.
Regards
Andy Grantham
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
There is no way to query the next or current sequence number without
causing it to increment. That is why even using dbschema causes them to
increment.
Art
Art S. Kagel, Principal Consultant
ASK Database Management
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
On Wed, Mar 5, 2014 at 4:59 AM, Andrew Grantham <agrantha@hotmail.com>wrote:
> All,
>
> Informix 10.00.FC10
> Sun Solaris
>
> All,
>
> Can someone tell me how I can determine the current sequence number for a
> sequence from the system tables or by using a command that does not affect
> the
> resulting value? Seemingly using dbschema or the select currval, nextval
> has
> an affect on the value returned.
>
> Regards
>
> Andy Grantham
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--089e01419f341b5cca04f3da5280
If you define cache size for sequence to 1, you can use following query to get
the current value. For larger cache size this query will not give you right
value.
select tabname sequence_name, c.cur_serial8 currval
from syssequences a, systables b, sysmaster:sysptnhdr c
where a.tabid = b.tabid and b.partnum = c.partnum;
sequence_name a_seq
currval 8
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.