Re: 4GL Question
Posted in 1993
} > i4gl version 4.00.UH1 } > ibm risc 6000 } > } > database xxxx } > } > main } > define lin_id INTEGER } > } > declare upd_curs cursor for } > select id } > from footable } > where foocol = 86 } > for update } You've locked the row (for update) } > } > begin work Start a transaction } > } > open upd_curs } > fetch upd_curs into lin_id } > } > display "FETCH: ", sqlca.sqlcode } > } > update footable } > set a_col = 1 } > where foocol = 86 } Since you have it locked it's ok } But you are going OUTSIDE your } cursor to do this update } > } > display "UPDATE 86: ", sqlca.sqlcode } > } > update footable } > set b_col = 2 } > where current of upd_curs } Now you are back into your cursor } It still has the old values, since } you didn't re-read. (???) } > end main } > } > ASSUMPTIONS: a_col = 0 and b_col = 0 before updates } > } > } > RESULT: All the sqlca.sqlcode are successes. } > } > a_col = 0 } > b_col = 2 } Last write wins. } > } > } > WHY ??? (granted why would you want to do this??? someone did that's why) } > } } The first update needs to be an update where current as well. } } j. } JacK: I tried switching the update with foocol = 86 to CURRENT OF upd_curs and it gave the right result. Next, I switched order where UPDATE WHERE CURRENT OF was first and UPDATE WHERE foocol = 86 followed, that, too gave the right results. What I have observed is that until a update where current of is processed, updates to that table for that specific row are ignored.