Am using a DB2 sequence object for a column which is a primary key to a table.
In a COBOL program, am fetching the next value of the sequence object in a working storage variable and incrementing that variable for the number of input records.
After processing all the input records i need to update the sequence object to the current value(value in the working storage variable).
Am using DB2 load utility and not the insert statements to load the table.
First time the load will go through fine. If i try to run the program and the load job again, then i need to update the latest value obtained in the COBOL program to the sequence object to avoid duplicate entries. Is it possible to update the sequence object in the program?
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
You shouldn't be using a sequence object as the primary key of a table. It is almost always discouraged and usually ends up causing problems like this. The normal reccomendation is to add a Timestamp field to the table and define the primary key as the "natural" key of the data.