5. Working with a Database : How You Can Access a Database with Standard SQL Statements : How You Can Use Cursors to Access the Database : How You Can Update or Delete a Row
 
Share this page                  
How You Can Update or Delete a Row
After you have fetched a row, you can update values in the row or delete the row if the cursor was opened to allow for updates and deletes. There are versions of the update and a delete 4GL statement specifically for use with cursors.
For example, the following code updates the customer record on which the cursor is currently positioned:
on click update_button =
begin
/* Actually update the customer in the database */
    if menu.get_menu.initial_account > 2 then
        update customer
        set acctno = :customer.acctno
        cphone = :customer.cphone,
        cname = :customer.cname,
        caddr = :customer.caddr,
        ccity = :customer.ccity,
        cstate = :customer.cstate,
        czip = :customer.czip,
        cdistrict = :customer.cdistrict,
        cstatus = :customer.cstatus,
        cacctbal = :customer.cacctbal
        where current of cust_cursor;
...
The following code provides an example of deleting the row on which the cursor is positioned:
on click delete_button =
begin
    if menu.get_menu.initial_account > 2 then
        delete from customer
        where current of cust_cursor;
...
For more information about the cursor version of the update and delete statements, see the Language Reference Guide.