DeleteRow method: Rowset class
Syntax
DeleteRow(n)
Description
The DeleteRow method deletes the row in the rowset identified by the parameter.
If the program is being run from a component against Component buffer data, a RowDelete PeopleCode event also fires, followed by the events that normally follow a RowDelete, as if the user had manually pressed ALT+8 and ENTER .
This method initially marks the row as needing to be deleted. At save time the row is actually deleted from the database and cleared from the buffer. When the row is marked as deleted, it is ignored by other methods, such as GetCurrEffRow, Sort, and so on.
DeleteRow cannot be executed from the same rowset where the deletion takes place, or from a child rowset against a parent. Place your PeopleCode in a parent rowset and execute it against a child rowset.
When DeleteRow is used in a loop, you have to process rows from high to low to achieve the correct results, that is, you must delete from the bottom up rather than from the top down. This is necessary because the rows are renumbered after they are deleted (if you delete row one, row two becomes row one).
Note:
If you use DeleteRow on a rowset created using the CreateRowset function, the row isn't automatically deleted in the database when the page is saved. Rowsets created using the CreateRowset function are standalone rowsets, not tied to the database, so there are no database updates when they are manipulated. Delete and insert activity on these types of rowsets aren't automatically applied at save time.
Parameters
| Parameter | Description |
|---|---|
|
n |
An integer identifying a row within the rowset object. This must be >= 1 and <= the number of active rows in the rowset (see ActiveRowCount). |
Returns
An optional Boolean value: True if row is deleted, False otherwise.
Example
In the following example DeleteRow is used in a For loop. The example checks a value in each row, then conditionally deletes the row. Note the syntax of the For loop, including the use of the -1 in the Step clause to loop from the highest to lowest values. This ensures that the renumbering of the rows do not affect the loop.
For &I = &RS2.ActiveRowCount To 1 Step -1
If None(&CHECK_SEQ) Then
&RS2.DeleteRow(&I);
End-If;
End-For;