I've been burned by this before. I even created an RFE asking IBM to change it.
http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=116091
-----Original Message-----
From: Craig Richards [mailto:craig@xxxxxxxxxxxxxxxx]
Sent: Thursday, June 14, 2018 7:41 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Identity Columns
Hi All,
I have some files with Identity Columns typically defined something like:
MsgCnt_UniqueID for column UniqueID Integer
not Null
generated always as identity ( start with 1 increment by 1 cycle ) primary key
When performing writes to a table with one of these fields using RGPLE RLA I thought that the UniqueID column in the RPG program was just ignored and a new unique ID assigned.
However I find I'm sometimes getting some duplicate key errors which are definitely with the Table ( not other indices ) and the primary key on the table is just the identity column.
Obviously with an SQL Write, I can specify a list of fields, excluding the identity column.
In RPG is it necessary to use Data Structures on the DB operations to also specify a list of fields which excludes the ID column?
I haven't convinced myself 100 percent, but this issue only seemed to appear when I was calling the program and then switching library lists and calling the program again.
There is a subfile program and maintenance screen which use the same service program for DB access which all run in Activation Group QILE. But these are called via a wrapper CL which does a RCLACTGRP between calls.
I'm a little stumped about what is causing this intermittent issue.
Is it dodgy to perform RLA with an identify column defined as above?
Or are there any special considerations I'm missing?
thanks kindly for any comments.
best regards,
Craig
As an Amazon Associate we earn from qualifying purchases.