3. Statements : OpenROAD SQL Statements : Update Statement : Update Mode
 
Share this page                  
Update Mode
The update mode of the cursor, specified when you opened the cursor, affects how you can use the update statement. You can open a cursor for deferred or direct update.
Deferred Mode
With deferred mode cursors, you can perform only one operation against each row. This operation can be an update or a delete but not both. Similarly, you cannot use the repeated option with a deferred update cursor. Cursors that are opened for direct update do not have these restrictions. However, if the cursor is a direct update cursor and you perform two cursor updates that are not separated by a fetch statement, you can update the same row twice.
After a successful update, OpenROAD sets the IIrowcount system variable to one. The cursor remains pointing to the same row (the State attribute of the CursorObject remains CS_CURRENT) and subsequent update or delete statements for the cursor take effect on the same row. If the update is not successful, OpenROAD sets IIrowcount to -1 or 0.
If the cursor is not pointing to a row, 4GL generates a runtime error message indicating that you must execute a fetch statement. If the row the cursor is pointing to has been deleted from the underlying database table (as the result, for example, of a non-cursor delete), no row is updated.
It is not necessary to commit after each cursor update. All the changes that you make are committed when you close the cursor. (Do not update the current row of a cursor, commit the change, and then continue in a loop in order to repeat the process. This process fails because the first commit statement closes the cursor.)
You must issue any update statements for a cursor in the same session in which you opened the cursor.
For more information about the update statement, see the Programming Guide.