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 > Sequence

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-04, 10:14
allian allian is offline
Registered User
 
Join Date: Dec 2004
Posts: 54
Angry Sequence

Hi,

Can anyone tell me where I can get all sequence's current value?


Allian
Reply With Quote
  #2 (permalink)  
Old 12-07-04, 10:59
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
Identity_val_local()
Reply With Quote
  #3 (permalink)  
Old 12-07-04, 16:06
nitingm nitingm is offline
Registered User
 
Join Date: Jul 2003
Location: Austin, TX, USA
Posts: 278
Sysibm.syssequences

hi.

I think you can get the same also by querying SYSIBM.SYSSEQUENCES table.

You can query the lastassignedval for the seqname.
__________________
HTH

Nitin

Ask the experienced rather than the learned
Reply With Quote
  #4 (permalink)  
Old 12-07-04, 16:32
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by urquel
Identity_val_local()
IDENTITY != SEQUENCE
Reply With Quote
  #5 (permalink)  
Old 12-08-04, 08:39
urquel urquel is offline
Registered User
 
Join Date: Aug 2004
Posts: 330
My bad. I guess I should read ALL of the words.
Reply With Quote
  #6 (permalink)  
Old 12-09-04, 13:20
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Nitin ,
The lastassignedval in the SYSIBM.SYSSEQUENCES gives the last cached value and not the last assigned one ..
Cheers
Sathyaram

C:\>db2 "create sequence seq2"
DB20000I The SQL command completed successfully.


C:\>db2 "select lastassignedval from sysibm.syssequences where seqname='SEQ2'"

LASTASSIGNEDVAL
---------------------------------
-

1 record(s) selected.


C:\>db2 "values(nextval for seq2)"

1
-----------
1

1 record(s) selected.


C:\>db2 "select lastassignedval from sysibm.syssequences where seqname='SEQ2'"

LASTASSIGNEDVAL
---------------------------------
20.

1 record(s) selected.


C:\>db2 "values(nextval for seq2)"

1
-----------
2

1 record(s) selected.


C:\>db2 "select lastassignedval from sysibm.syssequences where seqname='SEQ2'"

LASTASSIGNEDVAL
---------------------------------
20.

1 record(s) selected.


C:\>
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 12-09-04, 13:25
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
To answer the original question
PREVVAL FOR <sequence-name>
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #8 (permalink)  
Old 12-09-04, 16:02
nitingm nitingm is offline
Registered User
 
Join Date: Jul 2003
Location: Austin, TX, USA
Posts: 278
Cobweb Cleared.

Thanks Sathyaram for the wonderful explanation.

You have cleared a lot of cobwebs for many of us with your wonderful example.

Appreciate that!
__________________
HTH

Nitin

Ask the experienced rather than the learned
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