cancel
Showing results for 
Search instead for 
Did you mean: 

When is seq.NEXTVAL updated in a SEQUENCE?

10-06-2015 11:46 PM
932 views 2 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

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.

Thanks,

Donn

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Likes

This is a known docu-bug!

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

Former Member
0 Likes

OK, thanks!   I didn't find the note about this, perhaps because I was looking for an actual bug...

Donn

Answers (0)