I'm not familiar with Scott's JDBCR4 program.
If you are already using SQL to retrieve, I think it reasonable to try an SQL update to set "Processed" or "Error".
Assuming you are using C specs, the update could look something like:
* Update all consignment transactions for current outlet
C/EXEC SQL
C+ UPDATE cf20
C+ SET cf20.artnum = :C1ARTIN
C+ WHERE cf20.cnstyp = '6'
C+ AND cf20.artnum = :C1ARTOUT
C+ AND cf20.tranum IN (SELECT cf10.tranum
C+ FROM cf10
C+ WHERE cf10.tranum = cf20.tranum
C+ AND cf10.tranumsuf = cf20.tranumsuf
C+ AND cf10.cnstyp = cf20.cnstyp
C+ AND cf10.trasufext = cf20.trasufext
C+ AND cf10.outnum = :S1OUT
C+ )
C/END-EXEC
Note that fields :C1ARTIN and :S1OUT are RPG variables which supply values to the SQL statement.
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Kerins, Rebecca R.
Sent: Friday, May 29, 2015 6:54 AM
To: RPG400-L@xxxxxxxxxxxx
Subject: Select then update
I am currently creating a program using Scott's JDBCR4 program to retrieve unprocessed records from a db2 database on an AIX box. I am using SQL statements to retrieve the records and then I'm processing them in our legacy system using RPG and updating files on the iSeries. To do this I am looping thru the db2 database and that is working.
What I need to do at the end of the select is update the record selected with a status of "Processed" or "Error". I am not quite sure how to do this. I know there is a select for update SQL command but can that be used with the JDBC4?
Pseudo Code
1 Select unprocessed record from db2 database.
2 Process record on iSeries.
3 Update status on record from db2 database.
4 Go to step 1.
Any ideas you have would be appreciated.
Thanks!
Becky
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.