Let me get this straight.
You create a table with an autoincrementing column.
You create another table like that one via CRTDUPOBJ, CPYF, or a like
CREATE TABLE.
You perform activity on the original file like:
insert 1, 2, 3, 4, 5
delete 2, 5
update 1
Now you use CPYF to copy the entries from the original (1, 3, 4) to the
copy.
You insert a new row into the copy and you'd like it to use the next entry
from the source (6) and not whatever the increment counter is set to
(possibly 1 or 4, I've not tested this, which may be a duplicate key
issue).
Right?
CREATE TABLE ... LIKE ...
is supposed to include the identity column properties.
http://www-01.ibm.com/support/knowledgecenter/ssw_ibm_i_72/db2/rbafzhctabl.htm?lang=en
LIKE
table-name or view-name
Specifies that the columns of the table have exactly the same name and
description as the columns of the identified table (table-name) or view
(view-name). The name must identify a table or view that exists at the
current server.
...
If the LIKE clause is specified immediately following the table-name
and not enclosed in parenthesis, the following column attributes are also
included, otherwise they are not included (the default value, identity,
row change timestamp, and hidden attributes can also be controlled by
using the copy-options):
Default value, if a table-name is specified (view-name is not
specified)
Nullability
Hidden attributes
Identity attributes
...
IDK if this will do it:
Help for CRTDUPOBJ
Duplicate file identifiers . . . *NO
aka FILEID(*YES|*NO)
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.