Page 1 of 1

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

Posted: Thu 14 Jan 2016 10:48
by pcz
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.

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

Posted: Fri 15 Jan 2016 11:09
by AlexP
Hello,

Our products have no support for fkInternalCalc fields.

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

Posted: Fri 15 Jan 2016 11:37
by pcz
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?

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

Posted: Wed 20 Jan 2016 09:46
by AlexP
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.

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

Posted: Fri 22 Jan 2016 08:51
by pcz
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

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

Posted: Fri 22 Jan 2016 09:51
by AlexP
Yes, queries are generated basing on UpdatingTable. There was added an ability to generate this queries manually for such cases.

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

Posted: Fri 22 Jan 2016 12:19
by pcz
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

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

Posted: Mon 25 Jan 2016 09:44
by AlexP
Glad to see that you solved the problem. If you have any other questions, feel free to contact us