Logic behind temp-table

Subhransu

Member
Hi all,
I would like to know (in a client server environment) how does a browse intrenally work when it runs the query. That is how the records are fetched, where are the stored, whether all the records are fetched etc.?

Thanks.
Subhransu
 

RealHeavyDude

Well-Known Member
A browse widget has a query associated with it. That query has buffers associated with it which are either database tables or temp-tables. Therefore the query will run against the buffers associated with it. Whenever you select a row in the browse widget the query will fetch the corresponding records in the buffers so that they are in the record buffer. When you change fields they will be saved back to the buffers (either database table or temp-table).

The browse widget has a MAX-DATA-GUESS attributes which controls how many data the query will fetch, according to documentation the default value is 100. The vertical scroll bar of the browse widget is dependent on that setting too, the height of the scroll button is always in relation with the MAX-DATA-GUESS (and how many data is already fetched) not the maximum number of records in the table.

Heavy Regards, RealHeavyDude.
 

trx

Member
Actually, MAX-DATA-GUESS is estimated number of rows in query. You can set it to *expected* rows in query before you open query - it allows proper setting of vertical scrollbar (if you don't then Progress default is 100). After opening query it is constantly updated when you browse query and query reads new records. Finally, after all records have been read, it will be equal to number of records in browse, so if query is not filtered it will be number of records in table.

You can run this code and observe how MAX-DATA-GUESSS changes whilst you browse query or when you jump to the last row.
Code:
define query qryField for _field.

define browse browse-1 query qryField
    display _field-name
    with size 36 by 18.
    
define frame frame-1
    browse-1 at row 1 col 1
    with size 40 by 20.
    

open query qryField for each _field no-lock.    
enable browse-1 with frame frame-1.        

MESSAGE browse-1:max-data-guess.

on value-changed of browse-1
do:
    MESSAGE browse-1:max-data-guess.

end.

wait-for close of this-procedure.
 

Subhransu

Member
Hi,
If records are being fetched into local record buffer when we select them, how come we can see the columns of the records in the browse?

Thanks.
Subhransu
 

RealHeavyDude

Well-Known Member
You should be more specific on what you mean by "when we select them". Because, usually the browse widget does exactly that for you: Its query fetches the corresponding record into the record buffer whenever you click a row in it. When you want the browse widget to display a particular record via a custom logic you need to reposition the query behind the browse widget. If you use a FIND or a FOR EACH on the same buffer separate to the query then you screw up the query because there can only be one record at a time in the record buffer for a specific buffer. If that's your problem you need do define a named buffer to do the FIND (or FOR EACH) store the ROWID of that record and reposition the query behind the browse with the REPOSITION-TO-ROWID statement.

Something like that (coded in Firefox IDE - not syntax checked and tested) should do:
ASSIGN lOkay = BROWSE yourBrowseName:QUERY:REPOSITION-TO-ROWID ( yourRowid ).

Heavy Regards, RealHeavyDude.
 
Top