If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2 sequence object

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-09-09, 11:22
sgogula sgogula is offline
Registered User
 
Join Date: May 2009
Posts: 7
db2 sequence object

how do i access db2 sequence object to generate a unique sequence number?
Reply With Quote
  #2 (permalink)  
Old 07-09-09, 11:39
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Nextval For Seqname
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 07-09-09, 15:16
sgogula sgogula is offline
Registered User
 
Join Date: May 2009
Posts: 7
Quote:
Originally Posted by sathyaram_s
Nextval For Seqname
I dont know why this doesn't work for me in data studio. can i retrieve this using sql query like ' select Nextval for seq_name; ?
Reply With Quote
  #4 (permalink)  
Old 07-09-09, 16:04
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by sgogula
can i retrieve this using sql query like ' select Nextval for seq_name; ?
No, because this is an incomplete SQL query; it must have at least a FROM clause. Try "values nextval for seq_name" instead.
Reply With Quote
  #5 (permalink)  
Old 07-09-09, 17:14
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
or if you want to use SELECT, you can do

SELECT NEXTVAL FOR SEQNAME FROM SYSIBM.SYSDUMMY1

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #6 (permalink)  
Old 07-09-09, 22:18
sgogula sgogula is offline
Registered User
 
Join Date: May 2009
Posts: 7
Quote:
Originally Posted by sathyaram_s
or if you want to use SELECT, you can do

SELECT NEXTVAL FOR SEQNAME FROM SYSIBM.SYSDUMMY1

Cheers
Sathyaram
Thanks Sathyaram for the solution. This works perfectly.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On