Advanced PowerBuilder

HomePrevious Lesson: RetrieveStart Event
Next Lesson: RetrieveEnd Event

RetrieveRow Event

This event triggers immediately after retrieving each row and before displaying it on the screen. This is the right place to write the code, if you want to do some process on the row, before the user sees the row on the screen.

Writing code in this event and setting the Asynchronous option of the transaction object to TRUE, makes PowerBuilder to display the row on the screen, as soon as the code in this event is executed. For example, say the result set of a query has 10,000 rows. User will see the data on the screen only when PowerBuilder completes retrieving 10,000th row*. By writing code in this event (even a single line comment), user will see the data on the screen as soon as the first row is received by PowerBuilder (of course, code for this event is executed before it is displayed on the screen).

By writing code or comment increases the total time required to retrieve the result set. To reduce the time, you might want to write the code in the RetrieveEnd (explained later), which is executed after retrieving all the rows in the result set. Writing code for the RetrieveRow or RetrieveEnd depends on the application requirement.

* There is an exception to this behavior. If RetrieveAsNeeded option is set, PowerBuilder displays data as soon it completes retrieving one screen full of data. Whenever user tries to scroll down the screen, another screen full of data will be retrieved. PowerBuilder, depending on the DataWindow control size at run-time determines the number of rows that fit on a single screen.

Another exception is, you should not use aggregate functions�such as Sum(), Avg(), Min(), Max(), Count()�etc in the DataWindow and should not set the sort criteria in the DataWindow. In this situation, PowerBuilder needs the full result set in order to calculate the aggregate functions or to sort the data.

The following code displays the number rows retrieved on the status bar like a counter.


// Object: DataWindow dw_query in w_product_master window
// Event: RetrieveRow
w_mdi_frame.SetMicroHelp( "Rows Retrieved: " + &
                           String( row ) )
HomePrevious Lesson: RetrieveStart Event
Next Lesson: RetrieveEnd Event