By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,610 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,610 IT Pros & Developers. It's quick & easy.

Sequences in db2 8.1.0.36.

P: n/a

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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a

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.