There is no need to convert everything into SQL.
If the identity column is generated always, the new identity value is
determined correctly when writing a new record.
If you perform an SQL SET statement, with IDENTITY_VAL_LOCAL, the identity
value of your write operation.
Exec SQL SET :LastId = Identity_Val_Local;
We use this conjunction WRITE in RPG and Identity_Columns and
IDENTITY_VAL_LOCAL since years without any problems
Determining the highest identity value in the table with SQL might not be
the best idea, because in between your write and determining the highest
value an other program or job could have been written an other row.
With Identity_Val_Local you'll really get the Identity value of your WRITE
(even if a trigger gets fired that writes an other row into the same table
with a new identity).
Mit freundlichen Grüßen / Best regards
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Peter
Gesendet: Wednesday, 31.8 2016 23:03
Betreff: Re: Identity columns and RLA
Thanks Vern. I'm thinking I'll change the program to just use SQL for
everything, since it's simpler. But I was curious about mixing RLA and SQL.
On 8/31/2016 1:16 PM, Vernon Hamberg wrote:
There's an IDENTITY_VAL_LOCAL function you can use to get the last
assigned - it'd be an SQL statement, like SET or VALUES
On 8/31/2016 3:05 PM, Peter Dow wrote:
What happens when writing a record with RLA to a table that has an
Assuming it actually works, i.e. ignores the value in the identity
column on the WRITE, is there a way to get the value assigned to the
*Peter Dow* /
Dow Software Services, Inc.
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx> /