Page 1 of 1
How to use "RefreshRecord" for inserting records ?
Posted: Tue 13 Mar 2018 18:00
by luapfr
Hello, I would like to know if there is any functionality or some way to show when a Registry is entered without needing to use "Refresh" that takes too long in a large database.
Thankful.
Re: How to use "RefreshRecord" for inserting records ?
Posted: Wed 14 Mar 2018 08:35
by ViktorV
Please write in more detail what is the essence of your question and what you mean by the phrase "Registry is entered".
Re: How to use "RefreshRecord" for inserting records ?
Posted: Wed 14 Mar 2018 12:33
by luapfr
I've put together a small project so you can better understand what I need.
It is in Annex.
https://mega.nz/#!Miw3RTpA!De2KgFLO2c67 ... M8wZNt4UKc
Re: How to use "RefreshRecord" for inserting records ?
Posted: Wed 14 Mar 2018 15:02
by ViktorV
This behavior is correct: RefreshRecord is designed for actualizes field values for the current record, but not a newly added one.
When calling the RefreshRecord method, the query specified in the SQLRefresh property will be executed. If the SQLRefresh property is empty, IBDAC will automatically generate an SQL query when the RefreshRecord method is executed. If you manually set the SQLRefresh property to the required query, it will be executed when the RefreshRecord method is called.
To get the text of the SQL query sent to the server, when calling the RefreshRecord method, you can use dbMonitor.
To solve your task in your sample, you can replace the code line in your sample
with
Code: Select all
IBCQuery2.Last;
IBCQuery2.SQLRefresh.Text: = 'select * from table_test where id =' + IBCQuery1.FieldByName ('id'). AsString;
IBCQuery2.RefreshRecord;
IBCQuery2.SQLRefresh.Text: = '';
Re: How to use "RefreshRecord" for inserting records ?
Posted: Wed 14 Mar 2018 17:33
by luapfr
Hello I did what you said but it did not work.
Try this attached project.
https://mega.nz/#!Ij5FDKiD!uDQPm-_DqGai ... GLXs21_5ig
Do I have to activate any property ?
Re: How to use "RefreshRecord" for inserting records ?
Posted: Fri 16 Mar 2018 08:44
by ViktorV
Firebird does not provide the ability to obtain information about changes made in another query without requesting a server. To get the full changes made by other queries, you should use the Refresh method.
We said that the RefreshRecord method is for updating the current record in the dataset. In your sample:
- when there are no rows in your dataset - the call of the RefreshRecord method will not occur, because at the moment the recordset is empty and the current record is missing; - after adding the first record to the first recordset, you can call the Refresh method for the second dataset;
- if the dataset is not empty - the given current record of the second dataset is updated based on the information received after executing the query specified in the SQLRefresh property, but the new record in the second record will not be added.
Re: How to use "RefreshRecord" for inserting records ?
Posted: Fri 16 Mar 2018 11:40
by luapfr
the SQLInsert property would not be for this functionality ?
if so how could I use it ?
Re: How to use "RefreshRecord" for inserting records ?
Posted: Fri 16 Mar 2018 12:38
by ViktorV
The SQLInsert property is used to specify the SQL query that will be used when inserting into the current dataset, so its use does not apply to your task solution.
As we already mentioned, Firebird does not provide the possibility of obtaining information about changes made in another query without requesting a server. To get the full changes made by other queries, you should use the Refresh method.
Re: How to use "RefreshRecord" for inserting records ?
Posted: Sun 18 Mar 2018 11:21
by luapfr
Ah, I understand, thank you.
Re: How to use "RefreshRecord" for inserting records ?
Posted: Mon 19 Mar 2018 07:51
by ViktorV
Thank you for the interest in our products.
If you have any questions during using our products, please don't hesitate to contact us - and we will try to help you solve them.