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

jmerinoh

-----Original Message-----
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...

exec sql
update fileX
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?

Thanks

Tom Garvey

--
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,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.


This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 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].