By default the start with 1 cycle by 1 is how the file starts. So I leave
that phrase off.

But yes ALTER TABLE ADD COLUMN is what you would want to use.



On Fri, Apr 5, 2013 at 1:49 PM, Charles Wilt <charles.wilt@xxxxxxxxx> wrote:

I would hope that ALTER TABLE would work properly...though I've not really
tested it.

My experience with create table within the confines of an CMS showed the
problem. I ended up creating a little utility that was invoked using an
exit point in the CMS that would determine the highest current value of the
identity column and issue an ALTER TABLE ALTER COLUMN myID RESTART WITH
:MaxNbr + 1.

Also not that the GENERATED ALWAYS might be problematic when recreating the
table...as I believe unless you've never deleted anything from the table
and the system reads the original data in identity order, you'll find that
your identity columns get new values when the data is copied back.

Charles


On Fri, Apr 5, 2013 at 1:33 PM, Anderson, Kurt <KAnderson@xxxxxxxxxxxx
wrote:

Well, crisis somewhat averted, but I'm having an issue with an identity
field in a SQL created file.

Here's an excerpt from the table definition:
EditID Dec (10, 0) NOT NULL GENERATED ALWAYS AS
IDENTITY
(START WITH 1 INCREMENT BY 1
CYCLE),
Primary Key(EditID)

The file was created last October and has been fine all along. Today we
added a new field to the file and recreated the table. We copied the old
records in, and they retained their EditID values, so that was great.
However, the moment a record was added, it attempted to start at 1 again
and got a duplicate record error. Crap! To get around the issue, for
the time being, I modified the EditID definition to "START WITH 8060."
We're off and running again.

For every change to the file will the "START WITH" have to be modified?
Is there another way to get around this issue?

I have a feeling the answer might be to use ALTER TABLE instead of
recreating the file. It's not that I'm against that, it's just that I'm
already introducing a lot of change (new stuff) here, and I don't want
that
bubble to burst. In addition, we don't have change management software
(sigh), so I ended up creating a system to implement files across all of
our clients' libraries. To have to redesign it to know if the RUNSQLSTM
it
runs is executing a CREATE or an ALTER is a big deal.

I appreciate any input.

We're on IBM i 7.1.

Thanks,
Kurt Anderson
Sr. Programmer/Analyst
CustomCall Data Systems, a division of Enghouse Systems Ltd.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



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.