Can the counter field be the Primary Key of the table? If so, You can try using DDL to generate the table and then let SQL to control the counter and to return the latest ID generated.
Otherwise, the only thing that occurs to me after the update is:
SELECT MAX(counter) from fileX
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Thomas Garvey
Sent: Wednesday, April 11, 2012 10:48 AM
To: 'Midrange Systems Technical Discussion'
Subject: SQL Update value in RPG?
I'm using embedded SQL to update a counter in a database field, but would also like to know the new value of that counter without having to retrieve the newly updated record.
For example, using embedded SQL in my RPGLE, as follows...
set counter = counter +1
where keyfield = :something
I need to be able to control subsequent logic if the counter has reached a certain limit. I'd like to not have to re-retrieve the record to find out if the limit has been reached.
Anyone have any ideas?
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,
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l