Board index » delphi » TQuery that refreshes according to TTables additions / changes

TQuery that refreshes according to TTables additions / changes

I have a TQuery and TTable that takes data from the same table.
My TQuery is not live, I used it only for searching.

Is there a way in every AfterPost of the TTable to refresh only
the changed or added record in the TQuery ?
I want to refetch in the TQuery only the record that has
changed or to add a new record.

if I close and open again the TQuery everything is allright but
this is too slow for big tables.

Any ideas ?

Best Regards,
Vassilis Samaltanos
Digital Flow Software

 

Re:TQuery that refreshes according to TTables additions / changes


On Sat, 9 Oct 1999 16:04:06 -0700, "Vassilis Samaltanos"

Quote
<df...@technologist.com> wrote:
>Is there a way in every AfterPost of the TTable to refresh only
>the changed or added record in the TQuery ?
>I want to refetch in the TQuery only the record that has
>changed or to add a new record.

>if I close and open again the TQuery everything is allright but
>this is too slow for big tables.

For non-live queries closing and reopening is the only way to refresh
the query.  The reason is that the query result is a temporary table
that needs to be recreated for showing the new or changed records.

TQuery.Refresh will only re-evaluate filters or calculations on the
query result itself.

HTH,

Jan

Re:TQuery that refreshes according to TTables additions / changes


Thanks a lot Jan.
You are right. I spend two hours searching
about this problem in old posts in dejanews
but I didn't find anything different than closing
and opening the query.

I wonder if there is a way to have the query
records in packets like in TClientDataset.
That will improve the performace of the
close/open. What do you think ?

Vassilis Samaltanos

Re:TQuery that refreshes according to TTables additions / changes


On Sat, 9 Oct 1999 19:11:28 -0700, "Vassilis Samaltanos"

Quote
<df...@technologist.com> wrote:
>I wonder if there is a way to have the query
>records in packets like in TClientDataset.
>That will improve the performace of the
>close/open. What do you think ?

There is no way to do this.  But since you mention using Paradox
tables, are you sure that you can't use a TTable  instead of a TQuery?
You can use cached updates on a TTable just the same and performance
would probably be a lot better.

Jan

Re:TQuery that refreshes according to TTables additions / changes


Thank you very much Jan for all your answers.

The reason that I am using TQuery is because I have a
TPageControl with at least two pages.
In the first page I give to the user a list of the data in a grid
while in the second page I allow him to modify and insert records.
I use the TQuery so that I can allow him to put criterias.
I do not want to use a TTable and filters because
if I  have a filtered TTable with lots of records
the cursor moves really slow from record to record.

Finally  I convinced that I cant do anything to solve the
the TQuery refresh problem so I will have to change
my approach.

The temporary tables that you mentioned in the
 'What is the best way to cancel changes in a detail table ?'
thread, seam quite interesting.
I will try to create a temporary table from the TQuery result
and I will make the grid to show the contents of the temporary
table. When the user add/changes in the second page
I will do the same in the temporary table. How about
efficiency  or alternatives ?

Vassilis Samaltanos

Re:TQuery that refreshes according to TTables additions / changes


On Sun, 10 Oct 1999 17:57:36 -0700, "Vassilis Samaltanos"

Quote
<df...@technologist.com> wrote:
>The temporary tables that you mentioned in the
> 'What is the best way to cancel changes in a detail table ?'
>thread, seam quite interesting.
>I will try to create a temporary table from the TQuery result
>and I will make the grid to show the contents of the temporary
>table. When the user add/changes in the second page
>I will do the same in the temporary table. How about
>efficiency  or alternatives ?

IMO, this is a good approach to overcome this problem.  You can save
the result of a non-live query to a permanent table directly, so that
you don't have to batchmove:
  Check(DbiMakePermanent(Query1.Handle, 'TempDB.DB', True));
Now you can open this table via a TTable component.

There are also some good freeware in-memory table components that you
can use as an alternative to creating temporary tables.

Jan

Re:TQuery that refreshes according to TTables additions / changes


I Have the same problem and was considering doing the following:

Use a query to browse the records but with cached updates on
When a record is modified via another table or whatever  locate
the record in  the query  and copy changes to it
Cancel updates of the query to discard changes when the user
exits the form or  before requerying. This last step may not be
required.

I have not tried this method yet

Geoff Bien

Quote
>I have a TQuery and TTable that takes data from the same table.
>My TQuery is not live, I used it only for searching.

>Is there a way in every AfterPost of the TTable to refresh only
>the changed or added record in the TQuery ?
>I want to refetch in the TQuery only the record that has
>changed or to add a new record.

>if I close and open again the TQuery everything is allright but
>this is too slow for big tables.

>Any ideas ?

>Best Regards,
>Vassilis Samaltanos
>Digital Flow Software

Other Threads