Page 1 of 1

TMyQuery refresh only one field?

Posted: Mon 03 Feb 2020 09:47
by starhu
Hi,

I have a TMyQuery, let's say I have 3 fields: id, productName, quantity

Sometimes I need to refresh only the quantity fields because the table is very big.
How is this possible? I can't use the SqlRefresh because I use it for refreshing everything (I need this too, sometimes).
Thank you very much for your help!

Re: TMyQuery refresh only one field?

Posted: Mon 03 Feb 2020 10:45
by ViktorV
To quickly get changes made by other queries, you can use the TCustomDADataSet.RefreshQuick method. Note that for this method to work, it is necessary that the table has unique key fields and a TIMESTAMP field. You can get more information about this method in MyDAC help: https://devart.com/mydac/docs/devart.my ... olean).htm
For the TMyQuery.RefreshQuick method to work correctly, the timestamp field must be present in the SELECT query. If there are several such fields in the query, the last timestamp field present in the SELECT query will be used.
Note that the timestamp field in the database table should be as follows:
timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

Note, the query specified in the SQLRefresh property is used to refresh current record by calling the RefreshRecord procedure, but not the Refresh method.
You can find the detailed description of the property in IBDAC help: https://www.devart.com/mydac/docs/index ... efresh.htm
The query parameter value specified in the SQLRefresh property is automatically set to a value that is equal to the field value associated with this parameter before calling the RefreshRecord method.