467,154 Members | 685 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,154 developers. It's quick & easy.

Sequences in db2 8.1.0.36.


Hi All,
I am using IBM db2 version: 8.1.0.36.

The following code:

insert into t values (next value for s)
[
WHERE t is a table with single column of integer type.
s is a sequence I creates, which shows in the sysibm.syssequences.
]
gives me error saying "for" is an unidentified token.

When I run the same query in db2 8.1.7 it runs well.

Can any one please say what is the problem?
How can I use Sequence in db2???

Thanks and regards.
Ayusman
--
Ayusman
------------------------------------------------------------------------
Ayusman's Profile: http://www.dbtalk.net/m98
View this thread: http://www.dbtalk.net/t296807

Apr 3 '06 #1
  • viewed: 2121
Share:
3 Replies
Ayusman ,
Seems like u have encountered minor syntactical error
Ayusman wrote:
insert into t values (next value for s)
[
WHERE t is a table with single column of integer type.
s is a sequence I creates, which shows in the sysibm.syssequences.
] It should have been
insert into t values (NEXTVAL for s)
Much of the information can be found at
http://publib.boulder.ibm.com/infoce...d/c0007007.htm
gives me error saying "for" is an unidentified token.

When I run the same query in db2 8.1.7 it runs well.

Can any one please say what is the problem?
How can I use Sequence in db2???

Thanks and regards.
Ayusman
--
Ayusman
------------------------------------------------------------------------
Ayusman's Profile: http://www.dbtalk.net/m98
View this thread: http://www.dbtalk.net/t296807


Apr 3 '06 #2
Peri wrote:
Ayusman ,
Seems like u have encountered minor syntactical error
Ayusman wrote:
insert into t values (next value for s)
[
WHERE t is a table with single column of integer type.
s is a sequence I creates, which shows in the sysibm.syssequences.
]

It should have been
insert into t values (NEXTVAL for s)
Much of the information can be found at
http://publib.boulder.ibm.com/infoce...d/c0007007.htm

Note that NEXT VALUE FOR <seqname> is the SQL Standard syntax.
NEXTVAL was the syntax chosen by DB2 prior to sequences being added to
the SQL Standard.
So, moving forward please use NEXT VALUE FOR and PREVIOUS VALUE FOR for
compliance. NETXVAL and PREVVAL remain of course supported for backward
compatibility.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 3 '06 #3

Thanks a lot.
I was facing this proble.
But why does it work in db2 8.1.7??
--
Ayusman
------------------------------------------------------------------------
Ayusman's Profile: http://www.dbtalk.net/m98
View this thread: http://www.dbtalk.net/t296807

Apr 5 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by temp@mclift.fsnet.co.uk | last post: by
10 posts views Thread by Vilson farias | last post: by
4 posts views Thread by Hemant Shah | last post: by
1 post views Thread by J.Haan | last post: by
2 posts views Thread by Peteris Krumins | last post: by
3 posts views Thread by Ken | last post: by
4 posts views Thread by JJ | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.