Introduction to PowerBuilder

HomePrevious Lesson: Displaying Help in the Login Window
Next Lesson: Prompt for Criteria

Retrieve Only as Needed

This option is available in the DataWindow painter from the Rows menu and you must select it when you paint the DataWindow. The amount of data retrieved depends on the size of the DataWindow control. PowerBuilder automatically performs this calculation and adjusts the result display if you change the size of the control.

When the user starts scrolling down the DataWindow, PowerBuilder retrieves another screen full of data. A possible disadvantage of this method is, if you print the DataWindow, only the displayed rows are printed. This also has an effect on determining the number of rows a table has; you'll only receive a count of the number of current records.

Another effect of using this method is that the remaining information is held in the back-end database's memory, and this may use considerable system resources and affect the server's response time.

You can get round these problems by dynamically changing the 'Retrieve Only As Needed' status. For example, you could add the following line in the clicked event of the Print CommandButton at the beginning of the script, i.e., Print(TRUE) would be the last statement:
dw_product.modify(&
    "datawindow.retrieve.asneeded = false")
dw_product.Retrieve()

This cancels the Retrieve Only As Needed option, so all the information would be printed.

Note that if you specify a sort order using the Rows > Sort option, or if you use any aggregate functions such as sum() or avg() in the DataWindow painter, i.e., in the SELECT statement, then the Retrieve Only As Needed option will be ignored.
HomePrevious Lesson: Displaying Help in the Login Window
Next Lesson: Prompt for Criteria