How to use "RefreshRecord" for inserting records ?

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
luapfr
Posts: 37
Joined: Thu 11 Apr 2013 13:11

How to use "RefreshRecord" for inserting records ?

Post by luapfr » Tue 13 Mar 2018 18:00

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.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use "RefreshRecord" for inserting records ?

Post by ViktorV » Wed 14 Mar 2018 08:35

Please write in more detail what is the essence of your question and what you mean by the phrase "Registry is entered".

luapfr
Posts: 37
Joined: Thu 11 Apr 2013 13:11

Re: How to use "RefreshRecord" for inserting records ?

Post by luapfr » Wed 14 Mar 2018 12:33

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

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use "RefreshRecord" for inserting records ?

Post by ViktorV » Wed 14 Mar 2018 15:02

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

Code: Select all

IBCQuery2.RefreshRecord;
with

Code: Select all

IBCQuery2.Last;
IBCQuery2.SQLRefresh.Text: = 'select * from table_test where id =' + IBCQuery1.FieldByName ('id'). AsString;
IBCQuery2.RefreshRecord;
IBCQuery2.SQLRefresh.Text: = '';

luapfr
Posts: 37
Joined: Thu 11 Apr 2013 13:11

Re: How to use "RefreshRecord" for inserting records ?

Post by luapfr » Wed 14 Mar 2018 17:33

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 ?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use "RefreshRecord" for inserting records ?

Post by ViktorV » Fri 16 Mar 2018 08:44

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.

luapfr
Posts: 37
Joined: Thu 11 Apr 2013 13:11

Re: How to use "RefreshRecord" for inserting records ?

Post by luapfr » Fri 16 Mar 2018 11:40

the SQLInsert property would not be for this functionality ?

if so how could I use it ?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use "RefreshRecord" for inserting records ?

Post by ViktorV » Fri 16 Mar 2018 12:38

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.

luapfr
Posts: 37
Joined: Thu 11 Apr 2013 13:11

Re: How to use "RefreshRecord" for inserting records ?

Post by luapfr » Sun 18 Mar 2018 11:21

Ah, I understand, thank you.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use "RefreshRecord" for inserting records ?

Post by ViktorV » Mon 19 Mar 2018 07:51

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.

Post Reply