BEFORE DELETE block

The BEFORE DELETE block is executed each time the user deletes a row, before the row is removed from the list.

You typically code the database table synchronization in the BEFORE DELETE block, by executing a DELETE SQL statement using the primary key of the current row. In the BEFORE DELETE block, the row to be deleted still exists in the program array, so you can access its data to identify what record needs to be removed.

If needed, the deletion can be canceled with the CANCEL DELETE instruction.

When called in this block, the ARR_CURR() function returns the index of the row that will be deleted.

In this example, the BEFORE DELETE block removes the row from the database table and cancels the deletion operation if an SQL error occurs:
INPUT ARRAY p_items WITHOUT DEFAULTS
      FROM s_items.*
   ...
   BEFORE DELETE
     WHENEVER ERROR CONTINUE
     DELETE FROM items WHERE item_num = p_items[arr_curr()].item_num 
     WHENEVER ERROR STOP
     IF SQLCA.SQLCODE<>0 VALUES
       ERROR SQLERRMESSAGE
       CANCEL DELETE
     END IF
 ...