Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

When is seq.NEXTVAL updated in a SEQUENCE?

I'm planning on using SQL 'sequences' for serializing a reference table and am researching their use.  The examples given on page CREATE SEQUENCE - SAP HANA SQL and System Views Reference - SAP Library list the results expected, but on my HANA test, the values returned by the SELECT after the " INSERT INTO target VALUES ( seq.NEXTVAL, seq.NEXTVAL)" statement are "12, 12" and not "12, 13" as described.  It appears that the second NEXTVAL invocation in the statement does not cause the sequence to be incremented.  My HANA is at SPS09, version 1.00.091 (an older SPS06 server responds identically).

Is the example correct?  I can see why *not* incrementing the sequence would make sense, otherwise a mix of NEXTVAL (for the first one) and CURRVAL (for subsequent uses in the same statement) would be required.  I've searched the KB and find no bug describing an error with these symptoms.  If the actions of the SQL processor are valid, then please update the example given in the SAP Library.




This is a known docu-bug!

The example in the documentation is wrong. NEXTVAL gets evaluated once per record in a statement.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question