Progress
Programming
Handbook


Deleting Browse Rows

Deleting a record by way of a browse is a two-step process. When the user indicates a deletion, you should re-get the records EXCLUSIVE–LOCK NO-WAIT and then use the DELETE statement to remove the records from the database. Next, you would use the DELETE–SELECTED–ROWS( ) (plural) method to delete one or many selected records from both the browse widget and the query results list. DELETE–SELECTED–ROWS( ) is a newer and more efficient browse method and supercedes the old technique of using the DELETE–SELECTED–ROW( ) (singular) and DELETE–CURRENT–ROW( ) methods.

The code example below demonstrates an algorithm for deleting many rows from both the database and the browse. The technique also works for deleting single rows and records:

p-br11.p
DEFINE VARIABLE method-return AS LOGICAL. 
DEFINE BUTTON b-delete LABEL "Delete All Selected Rows". 
DEFINE QUERY q1 FOR customer SCROLLING.  
DEFINE BROWSE b1 QUERY q1 DISPLAY cust-num name ENABLE name 
    WITH 10 DOWN SEPARATORS MULTIPLE. 
DEFINE FRAME f1 
    b1 SKIP(.5) 
    b-delete 
       WITH NO-BOX SIDE-LABELS ROW 2 CENTERED. 
ON CHOOSE OF b-delete IN FRAME f1 
DO:  
    DEFINE VARIABLE i AS INTEGER. 
    DO i = b1:NUM-SELECTED-ROWS TO 1 by -1: 
        method-return = b1:FETCH-SELECTED-ROW(i). 
        GET CURRENT q1 EXCLUSIVE-LOCK.  
        DELETE customer. 
    END.  
    method-return = b1:DELETE-SELECTED-ROWS().  
END. 
OPEN QUERY q1 FOR EACH customer. 
ENABLE b1 b-delete WITH FRAME f1. 
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW 

A button indicates that the user wants to delete the selected rows. Since the record begins with NO–LOCK, you must first re-get the record with EXCLUSIVE–LOCK NO–WAIT. After using the DELETE statement, to remove the record from the database, the DELETE–SELECTED–ROWS( ) method updates the query and browse.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095