Refreshing single record / [fixed in 9.7.25] making active record remain same after refreshing dataset

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

Refreshing single record / [fixed in 9.7.25] making active record remain same after refreshing dataset

Post by pcz » Thu 14 Jan 2016 10:48

Hello

I've got a really stupid problem...

1. I've got TOraQuery component with NonBlocking mode turned on
2. I've got some fkInternalCalc fields and my SQL calculates their value based on one of fkData field values
Example: Field A is EMPLOYEE_ID, and field B is EMPLOYEE_NAME || ' ' || EMPLOYEE_LOGIN

3. I need to update value of these fkInternalCalc fields after editing a record
Example: I changed value of field A (EMPLOYEE_ID) so I want that field B value to be updated too

4. I need that dataset active record finally stays same as before editing


Idea 1.
There is a method "RefreshRecord"
But it doesn't seem to work... (or more likely I just cannot use it properly)
Does I have to fill SQLRefresh to make it work?


Idea 2.
Screw efficiency...
I tried to refresh all dataset...
But there is a problem on the ending - I'd like to active record stays same as before Refresh call
I had got a problem with GotoBookmark / Locate methods - they seems to not work until TOraQuery finishes execution
What is the best (or easiest way) to change active record to be the same as before refreshing?
Or maybe which events should I use?
Maybe any example? :P
(I've found that calling Locate inside AfterUpdateExecute is just a really stupid idea :P)


I'd be really grateful for help or any clues :)

Regards
P.C.
Last edited by pcz on Wed 29 Jun 2016 05:29, edited 1 time in total.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by AlexP » Fri 15 Jan 2016 11:09

Hello,

Our products have no support for fkInternalCalc fields.

pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by pcz » Fri 15 Jan 2016 11:37

Thanks for information.
Ok, I understand - "Idea 1" is just invalid :P
pcz wrote: I tried to refresh all dataset...
But there is a problem on the ending - I'd like to active record stays same as before Refresh call
I had got a problem with GotoBookmark / Locate methods - they seems to not work until TOraQuery finishes execution
What is the best (or easiest way) to change active record to be the same as before refreshing?
Or maybe which events should I use?
Maybe any example? :P
(I've found that calling Locate inside AfterUpdateExecute is just a really stupid idea :P)
What about using GotoBookmark / Locate in NonBlocking mode?
Inside which event handler should I call GotoBookmark / Locate?
Or what is the best way to wait for TOraQuery to fetch all data?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by AlexP » Wed 20 Jan 2016 09:46

If you don't use fkInternalCalc, then to update the field

Code: Select all

EMPLOYEE_NAME || ' ' || EMPLOYEE_LOGIN AS B
, you should set the RefreshOptions property to roAfterUpdate. In this case, a record will be re-read from the server after update.

pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by pcz » Fri 22 Jan 2016 08:51

The problem is that ODACs internal auto-generated query for RefreshOptions / RefreshRecord method are limited to only one table (UpdatingTable).

I just don't like to write extra SQLUpdate for every TOraQuery... So it's easier for me to refresh whole data

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by AlexP » Fri 22 Jan 2016 09:51

Yes, queries are generated basing on UpdatingTable. There was added an ability to generate this queries manually for such cases.

pcz
Posts: 81
Joined: Tue 04 Aug 2015 12:53

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by pcz » Fri 22 Jan 2016 12:19

Ok
It's not as complicated to change query SQL to fill SQLRefresh as it seemed to be...

Although it was a little tricky part to find how to insert records where primary key is generated by trigger
(extra use of RETURNING INTO / Options.ReturnParams)

Generally problem is solved :D :D :D
Thanks

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Refreshing single record / making active record remain same after refreshing dataset

Post by AlexP » Mon 25 Jan 2016 09:44

Glad to see that you solved the problem. If you have any other questions, feel free to contact us

Post Reply