How to update the data that has been fetched using a cursor in SQLRPGLE

By February 4, 2016 No Comments

So, normally I would go for SQLRPGLE for simple fetch operations but if I have to update the data in the file itself, I would normally rely on the trusty RPGLE command READ/READE/CHAIN and UPDATE/DELETE. Consider the following code.

Now earlier when I had do this using SQLRPGLE, I used to store the keys from the fetch into variables, do a CHAIN on an appropriate logical and perform UPDATE/DELETE. I find this extremely redundant. But I recently came across the concept of ‘where current of‘ followed by the cursor name. The above functionality can be achieved using the following manner.

A little explanation is by using CURRENT OF followed by the cursor refers to the last row that was retrieved using the cursor with the FETCH Command. This is also known as positioned update.


Author Naveen

A Computer Science graduate student, a programmer, photographer, reader and blogger

More posts by Naveen

Leave a Reply