Calculation fields question

Hello, I wondered before how Servoy handles calculated fields, now I have a specific issue: I have a table with some 40.000 records. I created a calculation, that works nicely. Then I wanted to use this field in a dynamic value list (by query), so I made this calculation stored. Then I figured, that only some records in the database were updated.

The question is: when I make a calculation stored, shouldn’t Servoy update all records according to the calculation? And if not, how do I force Servoy to do it?

Stored calculations are not calculated for all values immediatelyl. That is done on purpose for two reasons:

  1. It could be that you want to define more calculations and don’t want to wait until the ones you have defined are done updating
  2. It could be that you are creating calculations on a large record set in which case you might want to run the update directly on the back-end (if it is a calculation that can be expressed in SQL) and/or out of office hours.

To force an update of a calculation either write a loop that loops through all your records or execute an UPDATE statement directly on your backend database. We are considering to add a function to the define data providers section that will automate this procedure.

thanks for the reply. I think a function that updates the records for me would be useful. Of course, it can be done in SQL but then I have to think about the matter twice, once in JavaScript and once in SQL :D

Maybe you could add a button “update calculations” with a message saying “… could take a while etc.”. Now it is not absolutely clear which records are updated and which are not.

Hi Patrick,
as a matter a fact, I discussed this with dev team last week.
It’s been put on the req feature list.

Thanks for the input.

If your backend supports triggers this might be a pretty painless way to perfom the calculation(s) immedietly without having to submit a SQL command.

Yes, I know. But I want to keep my solution database independent, so I try not to use triggers or procedures because they don’t work with every database. Anyway, thanks for the tip.

Has this feature request has been implemented yet? I have a number of stored calcuation fields that I wanted them to update automatically when the data in the master record is updated.

Current I have to write scripts to update the related records using a find & then a foundset updater.

Thanks
Hameed