Flush method: Rowset class
Syntax
Flush()
Description
Use the Flush method to remove all rows from the rowset and free its associated buffer. Rows that are flushed are not deleted from the database. This function is often used to clear a work scroll before using the Select method.
Note:
Flush always leaves one row in the scroll.
You cannot flush the current context of the executing program. This means Flush cannot be used for the rowset containing the executing program, or in any child rowset and executed against the parent rowset. Place your PeopleCode in a parent rowset and execute it against a child rowset.
For rowsets corresponding to component buffer data, the Flush method executes in turbo mode only—that is, default processing is performed, but only on the row being flushed. Additional information on turbo mode and non-turbo mode is available in the documentation with the InsertRow PeopleCode built-in function.
Parameters
None.
Returns
None.
Example
The following example checks for the value of the field CHECKLIST_CD. If something exists in this field, the second level rowset is flushed and new values are selected into it.
If All(CHECKLIST_CD) Then
&RS1H.Flush();
&RS1H.Select(RECORD.CHECKLIST_ITEM, "where Checklist_CD = :1 and EffDt = ⇒
(Select Max(EffDt) from PS_CHECKLIST_ITEM Where CheckList_CD = :2)", CHECKLIST_CD,⇒
CHECKLIST_CD);
End-If;
Considerations When Initializing New Rows
Flush removes all rows and inserts a row.
If you want to initialize the row, that is, have the defaults and any RowInit PeopleCode run, you must do something to invoke the default value processing. This can be as simple as setting the value of another field on the same page that has a PeopleCode program associated with it.
If the rowset is created from message data, an Application Engine program, and so on, the rows are flushed but the row that is inserted is not initialized.
Considerations for User-Sorted Grids
If a grid has a user personalized sort defined for it and your PeopleCode program flushes that grid and then repopulates it (for instance, through a Fill, a Select, or a series of InsertRow calls), this could invalidate the user's personalized sort and the current row in the user's view unless your PeopleCode program makes arrangements to reapply these user personalizations.
After flushing and repopulating the rowset, your PeopleCode program should re-sort the rowset (that is, re-sort the grid). If the user has a personalized sort, then the user's personalized sort will be reapplied via the PeopleCode sort.
In addition, for classic applications only, after flushing and repopulating a grid, it will be important to manage which row is deemed the current row. This can be managed using methods such as IsUserSorted, GetFirstUserSortedRow, MapBufRowToUserSortRow, and then by setting the TopRowNumber property accordingly.
For example:
Local Rowset &rsGridResults = GetLevel0()(1).GetRowset(Scroll.PSWORKLIST);
&rsGridResults.Sort(PSWORKLIST.BUSPROCNAME);
/* For classic only, also identify the top row. */
If &rsGridResults.IsUserSorted("WORKLIST.PSWORKLIST") Then
&rsGridResults.TopRowNumber = &rsGridResults.GetFirstUserSortedRow("WORKLIST.PSWORKLIST").RowNumber;
End-If;