I want to have a column as the key field in a table. I like to have the value of the column as a pre-defined sequence number. How to do it in DB2? I know that in Oracle, you can do something like: CREATE SEQUENCE START FROM.... INCREMENT BY 1...... Thanks.
Unconfigured Ad Widget
Collapse
How to create a sequence number?
Collapse
X
-
How to create a sequence number?
If you use the RRN technique, make certain that you never delete records from the file and then reorg it. You could have duplicates in this case. Here's an example: you have 2 records in a file keyed by the RRN's 1 and 2 respectively. You delete the first record and reorg the file. The only record in the file now is keyed by the number 2. You then add in a 2nd record and *boom* duplicate key because the next RRN is 2 and the first record is already using that key. Chris
Comment
-
-
How to create a sequence number?
I have a SQL User-defined function written in C that may suit your needs. There are three different versions of it. One will start at 1 and increment by 1. The second will start at a value that is passed in and increment by one. The last, will start at the passed in value and increment using the second passed in value. The attached document contains the source and can be ftp'd to your AS/400. All Compile Options/Service Programs/SQL Functions are contained within the source/
Comment
-
Comment