Delete browse rows
- Last Updated: April 12, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Deleting a record by way of a browse is a two-step process. First, you need to delete the
record from the underlying temp-table or database table, and then you need to remove the
record from the browse itself, along with the query’s result list. If you are browsing a
database table directly and the user indicates a deletion, you should again get the
records by EXCLUSIVE-LOCK NO-WAIT and then use the
DELETE statement to remove the records from the database. In the
case of a temp-table, you can simply use the DELETE statement to remove
the records.
Next, you use the DELETE-SELECTED-ROWS() method to delete one or more
selected records from both the browse widget and the associated query result list.
To add a Delete button to the test window and use it to remove rows from the OlineBrowse and its temp-table:
- Drop another button onto the window called btnDelete and give it a label of Delete OrderLines.
- Write this
CHOOSEtrigger for the new button:DO: DEFINE VARIABLE iRow AS INTEGER NO-UNDO. DO iRow = 1 TO hBrowse:NUM-SELECTED-ROWS: hBrowse:FETCH-SELECTED-ROW(iRow). DELETE ttOline. END. hBrowse:DELETE-SELECTED-ROWS(). END.Because the OlineBrowse is a multiple-selection browse, you can use it to delete one or more rows at once. This code walks through the set of selected rows and retrieves each one in turn using the
FETCH-SELECTED-ROWmethod. This method repositions the temp-table query to that row, so that it can be deleted. The code then uses theDELETE-SELECTED-ROWSmethod to delete all the rows from the browse itself, along with the query’s result list entries for them.If you run the test window, you can now delete one or more rows from the list of OrderLines for an Order. Remember that these records are deleted only from the temp-table. You would have to make a call to a procedure connected to the database to pass the list of rows to delete from the database table.