Unit Bwfetch

**************************************************************************} (* TBW_QueryFetch This component is a descendant of tcomponent and works, paired with a TQUERY (or a descendant such as TwwQuery), to give a pseudo interruptable query. Its purpose is to combine executing a query with fetching the records. Standard TQueries only fetch the records that they need to display which can cause problems and inconsistancies when the records need to be used. For example if a user is browsing the results of a query of 100,000 records via a dbgrid the query will fetch perhaps only the first 20 records. If they press pagedown, the query selects the next 20 rather quickly. If the user presses the END key, Delphi attempts to go to the EOF. This could take a very long time and is not interruptable. The user might easily think the machine is hung. Since Query1.recordcount forces the same thing (all records to be selected) you can't even warn the user when they're working with a huge result set or not. So the user has no way of knowing when things will take a long time or not. This can also come up if a programmer has opted to do some sort of record level processing in Delphi on a query result set. (as opposed to writing a stored procedure). The processing time is totally dependant on the number of records in the result set - which you don't know until its too late! Processing time could easily exceed the users expectation and possibly swamp the Delphi prog running on the front end PC. So if you need to do local processing, determine the number of records, or allow the user to browse the result set, then your open to get this potentially devestating performance hit. Here's the good news: once records have been fetched, you can move around them very quickly. Its just the first time you access records that its slow. BDE caches the records for you so it doesn't need to return to the server. This component is a way to help the situation. It starts out by merely executing a query in a standard way (I know of no way to interrupt the query on the server via BDE). Then it scans the open query in a loop and just does a query.next. This fetches the records one at a time. In between the iterations of the loop, it maintains a progress dialog (and a counter) and allows the user to interrupt the loop. If the user interrupts the fetching of records, then the query can be closed. If you don't close the query when they cancel it but let the user navigate the records, then they're still susceptible to the performance hits if they do something that causes a 'go to End of table' Its up to you to trap and protect them from this if you set CloseOnCancel := false ; So with this component the user is aware of what is happening and can interrupt the operation. This was designed to work with an add-hoc query system. If the user selects too many records, then they can cancel the query, and refine their search criteria. The key method is called Execute. There are a just a few simple properties that should be self evident. DisplayDialog = true ; shows the working form. (with this set to false there is no way to cancel the query except if it exceeds the maxrecords value) CloseOnCancel = true ; will close the query if they press the stop button or press the escape key. Interruptable = true ; specifies that the fetch operation can be canceled. MaxRecords = # ; specifies the maximum number of records to fetch before auto-canceling the fetch operation. Set it to -1 for no maximum. IncRecordCound = # ; specifies the number of records to fetch before updating the dialog's counter. DialogCaption = string ; is the caption displayed on the progress form. EnableFetch = True ; this specifies if the component does the fetch after opening the query. If False, it just opens the query. { the companion unit is called fwrking1.pas - don't forget fwrking1.dfm too. } - Bill Wolf 12/8/95 *) (* Modification History 1/30/96 - added fQuery.disablecontrols to speed fetch operation. *) {

Classes

TBW_QueryFetch -

Functions

Register -

Types

Constants

Variables


Functions


procedure Register;


Types


Constants


Variables