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 > Please help:Sequence question?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-03-07, 17:55
mary76 mary76 is offline
Registered User
 
Join Date: Jan 2007
Posts: 3
Please help:Sequence question?

Hi All,

I have created a sequence and my sequence number should not restart with 1 after reaching the maximum value.After reaching the maximum value 100 it should give error.Please reply to this query

please find below the code :
CREATE SEQUENCE pos AS INTEGER START WITH 1 INCREMENT
BY 1 MAXVALUE 100 CYCLE CACHE 5

ALTER SEQUENCE pos RESTART WITH 1 INCREMENT BY 1
MAXVALUE 100 CYCLE CACHE 5


Thanks to all.
Reply With Quote
  #2 (permalink)  
Old 02-04-07, 03:31
guyprzytula guyprzytula is offline
Registered User
 
Join Date: Jun 2006
Posts: 471
sequence

I don't think this is possible.
in that case you have to maintain it yourself and save it in a table
__________________
Best Regards, Guy Przytula
DB2 UDB LUW certified V6/7/8
Reply With Quote
  #3 (permalink)  
Old 02-04-07, 18:34
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by mary76
I have created a sequence and my sequence number should not restart with 1 after reaching the maximum value...

please find below the code :
CREATE SEQUENCE pos AS INTEGER START WITH 1 INCREMENT
BY 1 MAXVALUE 100 CYCLE CACHE 5
If you don't want it to cycle, why do you define it with CYCLE?
Reply With Quote
  #4 (permalink)  
Old 02-05-07, 01:47
vini_srcna vini_srcna is offline
Registered User
 
Join Date: May 2006
Posts: 82
I dont have much idea about SEQUENCE. I think you can put a check constraint for that column like all the values should be less that 100. I agree this may not be a good idea, if you have the option of controlling it in SEQUENCE object itself.
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