× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Arco,

Thanks for taking the time to reply.

My code also seemed to be working fine with RLA and generated always
columns until I did a couple of quick tests to make sure the named
activation group was being cleaned up, which involved switching library
lists and then I seemed to get the intermittent problem.

I noticed when switching environments and inserting records that it seemed
to skip one identity value ( e.g the highest INT ID I had was 12 and it
would generated 14 instead of 13 as the next number )
I know this makes it sound like I've leaving something open but I'm sure I
am not. Although there are 2 programs and a service program involved, only
the service program does database I/O. Both programs run in QILE and end
with *INLR. The Service Program runs in *CALLER and closes all files and
cursors ( of which there are very few ) and the Activation Group is being
reclaimed so I can't see what resource might be left around.

I notice that you are using DS for I/O whereas I am not.

I think I will leave the program as it is for now and see if I can find a
way to recreate the problem to better understand it.

But thanks for your reply - it's good to hear that other people are using
GENERATED ALWAYS ID columns with RLA without issues.

best regards,
Craig



On 14 June 2018 at 16:04, Arco Simonse <arco400@xxxxxxxxx> wrote:

Hi Craig,
You do not need to omit the identity column from your write. We use RLA
write/update of tables defined with GENERATED ALWAYS in many programs here.
Here's a substract of how we do this. Sorry, not totally free code but I'm
to short of time to beautify it.
Hope that helps.
Regards,
-Arco


fadminmas uf a e k disk commit usropn
f alias qualified
d wwFileIn...
d ds likerec(adminmas.adminmasrf
d :*input)
d wwFileOut...
d ds likerec(adminmas.adminmasrf
d :*output)
d based(wwFilePtr)
d wwFilePtr...
d s * inz(%addr(wwFileIn))
/free

clear wwFileIn ;
chain formPanel1ID.id1 adminmas wwFileIn ;
// copy records from posted datastructure
eval-corr wwFileOut = formPanel1Rec ;
if not %found(adminmas) ;
write(e) adminmas.adminmasrf wwFileOut ;
if %error ;
peErrMsgHasSet = MSGHND_composeFileIOErrorMessage
( %status : curPortalLang : pePostVarName
);
return FALSE ;
endif ;
wwIDval = rtvLastProvidedID() ;
formPanel1ID.id1 = wwIDval;
else ;
update(e) adminmas.adminmasrf wwFileOut ;
if %error ;
peErrMsgHasSet = MSGHND_composeFileIOErrorMessage
( %status : curPortalLang : pePostVarName
);
return FALSE ;
endif ;
endif ;

return TRUE ;
/end-free



2018-06-14 14:41 GMT+02:00 Craig Richards <craig@xxxxxxxxxxxxxxxx>:

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
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.