Progress
Programming
Handbook
Creating Browse Rows
In an updatable browser, you might want to allow the user to add new records to the database. Programmatically, this requires three separate steps:
NOTE: You can use the INSERT–ROW() browse method in an empty browser. It places a new row at the top of the viewport.- Create a blank line in the browse viewport with the INSERT–ROW() method and populate it with new data.
- Use the CREATE statement and ASSIGN statement to update the database.
- Add a reference to the results list with the CREATE–RESULT–LIST–ENTRY( ) method. (This step is only necessary if you do not plan to reopen the query after the update. However, this method makes reopening the query unnecessary for most applications.)
All three steps are required to create the record and keep the database, query, and browse in sync. Also, there are several possible side effects to allowing the user to add a record through an updatable browse. They include placing new records out of order and adding records that do not match the query. To eliminate these side effects, you can reopen the query after each new record.
The code example below shows one possible algorithm for creating new records with an updatable browse:
In this example, the user requests a new record by choosing a button. The button triggers the INSERT–ROW( ) browse method. This method takes two possible strings: BEFORE and AFTER, indicating where to place the new record—before or after the current selected row. The method places a new blank browse row in the browse viewport. The method has no effect on the database or the results list of the query.
Since you know that you have allowed the user to add new rows, you have to check for them. A ROW–LEAVE trigger provides the perfect vehicle for checking for this special case. Because the code does not contain the NO–ASSIGN option of the DEFINE BROWSE statement, the normal default row assignment occurs for updated existing records.
The NEW–ROW attribute tells you whether the current row is a new one. When you encounter one, you have to create a new blank database record and populate it with all the necessary data, which may come exclusively from the browse or from a mixture of sources. In this example, the item-num is generated by an existing database sequence.
At this point, the browse has correct data, the database has correct data, but the query results list does not. The CREATE–RESULT–LIST–ENTRY() method takes care of this task.
The following screen shows a new record being entered into the browse:
![]()
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |