ZQuery RefreshCurrentRow

The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!

My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
Post Reply
Bill74
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 10.12.2016, 09:43

ZQuery RefreshCurrentRow

Post by Bill74 »

Hello,

I am developing under Delphi. In my application, there are a ZQuery1 and a ZQuery2.
the role of this ZQuery2 is to update the ZQuery1. To display the changes to the user of my application, I have to go through "ZQuery1 .Refresh".
The ZQuery2 contains 300000 records, so it takes several seconds to display these changes.
I want to display only the update of row without going through a "refresh" of the ZQuery2 .
I saw that there is the property "RefreshCurrentRow". I wrote :
"ZTable1.RefreshCurrentRow (FALSE);"
But, there is no visible change.

- ZQuery1 SQL (Select... From...).
- ZQuery2 SQL (Update... Set...).

How to display the update of a one row of a ZQuery1 please?

Thank you

Delphi + ZEOSDBO-7.2.4-stable.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: ZQuery RefreshCurrentRow

Post by marsupilami »

Hello Bill,

why don't you just do the changes in ZQuery1?

Code: Select all

ZQuery1.Edit;
ZQuery1.FieldByName('foo').AsString := myStringValue;
ZQuery1.FieldByName('bar').AsInteger := MyIntegerValue;
ZQuery1.Post;
This way ZQuer1 always will know the current state of the record?

Best regards,

Jan
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: ZQuery RefreshCurrentRow

Post by Fr0sT »

Hmm, how did you manage to execute this method? I receive "The refreshrow method is only supported with an update object." with query as well as table.
Anyway +1 for trying to implement this method, it could be very useful.
Bill74
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 10.12.2016, 09:43

Re: ZQuery RefreshCurrentRow

Post by Bill74 »

Hello,
I thank you for your answer.

- marsupilami:
yes, your code does the job but I do not want to go through:
"Edit" and after "Post" because my application works on LAN and many users are connected to it, and for not having much charge in the LAN.

- Fr0sT :
I execute this method : TQuery (with "OpdateObjet" propriety to "ZUpdateSQL") + ZUpdateSQL.
This is normally compiled but, there is no refresh of the Query.

Best regards.

Bill
Fr0sT
Zeos Dev Team
Zeos Dev Team
Posts: 280
Joined: 08.05.2014, 12:08

Re: ZQuery RefreshCurrentRow

Post by Fr0sT »

Bill74 wrote:I execute this method : TQuery (with "OpdateObjet" propriety to "ZUpdateSQL") + ZUpdateSQL.
This is normally compiled but, there is no refresh of the Query.
That's weird, things should work. More to say, from the 1st sight I see no reasons why this couldn't work even without UpdateObject
markus
Senior Boarder
Senior Boarder
Posts: 58
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

Re: ZQuery RefreshCurrentRow

Post by markus »

Hi,

Is there a way to fetch only one row from database?
I tried RefreshCurrentRow - with error quoted by Fr0sT.
I would like to avid Edit...Post dataset update method since this post data back to DB and i need to avoid this.

Best regards,
Marek
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: ZQuery RefreshCurrentRow

Post by marsupilami »

Hello Marek,

this seems like a job for CachedUpdates? Or is there anything I didn't understand?
Best regards,

Jan
markus
Senior Boarder
Senior Boarder
Posts: 58
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

Re: ZQuery RefreshCurrentRow

Post by markus »

Jan,

I've got editable grid with a lot rows - 30k+
After editing one row Postgresql trigger changes data on other rows (5 to 10 rows).
Application is then notified of changed rows id's.
I need to fetch data for these rows from DB.
Edit() ... Post() method is sending data to DB again, and i want to avoid it.
Is there a way to change data in TZQuery without sending it to DB?
Ideal would be for me to perform RefreshCurrentRow on each of rows that i need to fetch data from DB.

Best regards,
Marek
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: ZQuery RefreshCurrentRow

Post by marsupilami »

Hello Marek,

I am sure, you know that keeping 30k+ rows in a GUI application is usually seen to be bad practice?

Anyway. Currently this will only work using an TZUpdateSQL object. Drop it next to your dataset. Link it and fill out the properties for ModifySQL, DeleteSQL and InsertSQL and for RefreshSQL. Then start praying ;)

Background for others: Currently the method RefreshCurrentRow of the TZGenericCachedResolver will always throw an exception. The only way to circumvent this is the use of the TZUpdateSQL object. A better logic would be nice but we don't have it currently. Ticket #262 tracks this feature request.

Best regards,

Jan
markus
Senior Boarder
Senior Boarder
Posts: 58
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

Re: ZQuery RefreshCurrentRow

Post by markus »

Jan,

In this case rows number is varied, based on parameters that user supplies...

Anyway i've used TZUpdateSQL but in selective way:
i suppky only RefreshSQL to it, and attach it to ZQuery in ZQuery->AfterPost.
Then i locate each ID i neet to refresh, and call ZQuery->RefreshCurrentRow(false).
After refreshing all rows that i need i detach ZUpdateSQL from ZQuery

And it works:)

Best regards,
Marek
Post Reply