×
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.
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.
As an Amazon Associate we earn from qualifying purchases.