× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



One solution is to create a sequence object, and then initialize the
sequence object to start at the next number you mention in your e-mail.

Once the sequence object is created and initialized, you can use it in a
join to get the next number for all rows.

The sequence object takes care of incrementing its value so each
subsequent row has a unique value, assuming you run with
the appropriate isolation and start with a unique value.

Sequence objects are specially built data areas that DB2 Sql knows how to
use

Here is some example code showing how to create a sequence:

CREATE SEQUENCE mylib/mySeqObj
START WITH 0 <- You can
set your initial value here, or in the next step
INCREMENT BY 1
MAXVALUE 999
CACHE 1000


Here is how you can re-set an existing sequence object:

ALTER SEQUENCE myLib/mySeqObj RESTART WITH 999 <-
Obviously, 999 can be (almost)
any value you choose

Here is an example using the sequence object

INSERT INTO myLib/myTable2
SELECT col1 AS colA,
col14 AS colB,
NEXT VALUE FOR mySeqObj AS colC
FROM Lib01/TableX
ORDER BY 1


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.