Accessing sequence's currval
Posted in 2015
Topics: General Discussion
Hello everybody, I just want to read a sequence's current value but don't want it to be incremented. Is there a way to access a sequence's currval without first accessing nextval?. Thanks a lot, Juan
Hello. Follow the official documentation link: http://www-01.ibm.com/support/knowledgecenter/SSGU8G_12.1.0/com.ibm.sqls.doc/ids _sqs_1461.htm?lang=en-us Currval should work, check your code, and if you have any issue, paste it here, with the error, and we can give you some help. Best regards. Alexandre Marini IBM Informix Certified Professional v10 / v11.50 / v11.70 / v12.10 IBM Information Management Informix Technical Professional IBM Certified Developer - Informix Genero BRIUG website administrator Informix independent consultant > To: ids@iiug.org > From: jluis.roca@hotmail.com > Subject: Accessing sequence's currval [36036] > Date: Tue, 10 Nov 2015 04:06:15 -0500 > > Hello everybody, > I just want to read a sequence's current value but don't want it to be > incremented. > Is there a way to access a sequence's currval without first accessing > nextval?. > > Thanks a lot, > > Juan > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. >
Thank's Alexandre,
But I need to access NEXTVAL to get CURRVAL, and that is what I want to avoid.
Otherwise the following error appears:
8315: Sequence (jlrbcnpr.seq_2) CURRVAL is not yet defined in this session.
when executing:
select seq_2.currval from tab1
I see. What is the problem of using nextval first? When you use a sequence, you may expect some gaps in generated values, you cannot ensure 100% of contiguous numbers.... it must be acceptable.
No, there is no way to read a sequence's value without incrementing it. Art Art S. Kagel, President and Principal Consultant ASK Database Management www.askdbmgt.com 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 Tue, Nov 10, 2015 at 4:06 AM, JUAN ROCA <jluis.roca@hotmail.com> wrote: > Hello everybody, > I just want to read a sequence's current value but don't want it to be > incremented. > Is there a way to access a sequence's currval without first accessing > nextval?. > > Thanks a lot, > > Juan > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --001a113ff826ccc4e805242dcb00