Search code examples
ibm-midrangerpglerpg

How to update a file using a CURSOR in SQLRPGLE


Can someone tell me how to update a data using the CURSOR in sqlrpgle.Is there a way updating data just by using CURSOR rather than using the Update statement in SQLRPGLE?


Solution

  • What update statement do you refer to ? UPDATE rpg order or UPDATE SQL ?

    With UPDATE SQL :

      Exec SQL declare c1 cursor for
         SELECT *
            FROM xxxx ..
         for update ;   
    

    fetch the records as usual , and before each fetch :

     exec sql
          update xxxxx  set FIELD = :FIELDRPG
          where current of c1;