Board index » delphi » CachedUpdate query.

CachedUpdate query.

I have to use query joined two tables and I have to modify one of that
tables. For this I use CachedUpdate and TUpdateSQL component. All would be
well but it seems doesn't want update my query. I need to call
query.ApplayChanges method for it. I want applay changes immediately after
record was inserted, modified or delited. So my TQuery would works like
TTable.

What is place where I must call query.ApplayChanges if I insert, delete and
modify that query from anywhere in my program? Why delphi can't do insted
me?

--
With best regards, Dmitry
email: Di...@diogen.nstu.nsk.su
http: //diogen.nstu.nsk.su/~Dmitry

 

Re:CachedUpdate query.


Quote
>What is place where I must call query.ApplayChanges if I insert, delete and
>modify that query from anywhere in my program? Why delphi can't do insted
>me?

That is one of the "features" about CachedUpdates.  It allows you to control
WHEN  you do the update.  Delphi doesn't do it because you are doing a join and
joins, in the Sql sense, are always returned read only.

A couple of places to look at executing ApplyUpdates is in the TDataSource's
OnDataChange event or the TDataSet's AfterScroll event.

HTH

********************************
Michael Glatz              
glatzfa...@aol.com
mgl...@briefcase.com
There are very few personal problems that cannot be solved through a suitable
application of high explosives.

Re:CachedUpdate query.


On Fri, 26 Mar 1999 17:31:27 +0600, "Dmitry M.Ivlev"

Quote
<Di...@diogen.nstu.nsk.su> wrote:
>I have to use query joined two tables and I have to modify one of that
>tables. For this I use CachedUpdate and TUpdateSQL component. All would be
>well but it seems doesn't want update my query. I need to call
>query.ApplayChanges method for it. I want applay changes immediately after
>record was inserted, modified or delited. So my TQuery would works like
>TTable.

>What is place where I must call query.ApplayChanges if I insert, delete and
>modify that query from anywhere in my program? Why delphi can't do insted
>me?

One applicable place might be in a handler for the AfterPost event. The
AfterPost event fires after successful completion of a post operation,
whether the record was new or just modified.

Warning, though: to keep the cache and base table synchronized, you need to
refresh (close and reopen) the TQuery after calling its ApplyUpdates
method. This means that if you want to resposition the record pointer to
that last row the user was working with you would need to use a bookmark or
some other means for "remembering" its position.

//////////////////////////////////////////////////////////////////////////
Steve Koterski                 "Like a camel, I can go without a drink for
Technical Publications         seven days--and have on several horrible
INPRISE Corporation            occasions."
http://www.borland.com/delphi                                 -- Herb Caen

Other Threads