Positioned UPDATE and DELETE Statements

Positioned UPDATE and DELETE statements are used in conjunction with cursors and include WHERE CURRENT OF clauses instead of search condition clauses. The WHERE CURRENT OF clause specifies the corresponding cursor.

     EXEC SQL
         UPDATE emp SET last_name = :last-name
          WHERE CURRENT OF Cur1
     END-EXEC

This will update last_name in the row that was last fetched from the database using cursor Cur1.

     EXEC SQL
         DELETE emp WHERE CURRENT OF Cur1
     END-EXEC

This example will delete the row that was last fetched from the database using cursor Cur1.

OpenESQL

With some ODBC drivers, cursors that will be used for positioned updates and deletes must include a FOR UPDATE clause. Note that positioned UPDATE and DELETE are part of the Extended ODBC Syntax and are not supported by all drivers.