DB2: Sequences
Unique numbers, love 'em hate 'em, just got a have 'em some time. I have been experimenting with DB2 over the last few weeks and it supports a construct that I was unaware of: sequences.
To create a sequence do this:
CREATE SEQUENCE DB2ADMIN.EREPORTNO START WITH 1 INCREMENT BY 1 NOMAXVALUE
NOCYCLE CACHE 24
To use the sequence do this:
INSERT INTO DB2ADMIN.EREPORTS(NAME, ADD1, SEQ) VALUES ("Cheesey","peas",NEXTVAL FOR DB2ADMIN.EREPORTNO);
This will stick the record in the table with the SEQ field equal to the next EREPORTNO value. Lovely.
Dosn't work in partitioned databases tho. No suprise there, same as all those unique value attempts we domino charlies made.
Beep Beep.
<< Home