× 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.



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

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"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)



-----Ursprüngliche Nachricht-----
Von: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Peter
Dow
Gesendet: Wednesday, 31.8 2016 23:03
An: rpg400-l@xxxxxxxxxxxx
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

HTH
Vern

On 8/31/2016 3:05 PM, Peter Dow wrote:
What happens when writing a record with RLA to a table that has an
identity column?

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
identity column?

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx> /




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.