Advanced PowerBuilder

HomePrevious Lesson: Scrollable Cursors
Next Lesson: Deleting Through a Cursor

Updating Through a Cursor

An application can update or delete a row to which the cursor currently points in the result set, using CURRENT. For example:
UPDATE "product_master"
SET "product_balance" = product_balance + 100 
WHERE CURRENT OF lProductMasterCursor1 ;

In this example, instead of using a WHERE clause, we give the name of the cursor. This updates the row at the current cursor position - suppose you fetch four items and issue this command, the fourth row is the one that gets updated. Updating a cursor doesn't change the row position in the result set. There are few points to remember when updating using a cursor:

DECLARE <CursorName> [ SCROLL | NO SCROLL | DYNAMIC SCROLL]
CURSOR FOR <Statement> [ FOR UPDATE | FOR READ ONLY ]
HomePrevious Lesson: Scrollable Cursors
Next Lesson: Deleting Through a Cursor