How can I fill automatically a stored calculation?

Hi there…

Scenario: table with data on it and, for some reason, I need to create a stored calculation.

How can I fill automatically the column for all the existing data?
Is there a way to avoid loop all records manually?

Will be better to create a form that fill the new column or it’s even better fill directly the column from the DB?

Thanks,


Federico Galluzzo
Area 5578

Hi Federico,

  1. write a method which loops through all records of the table and call databaseManager.recalculate() for each record.
    Mind you, this will also trigger other calculations.

Depending on the number of records this can be a slow process.

  1. use an update statement on your SQL database.
    This might be difficult depending on the calculation you did.
    You can execute an update statement through the rawSQL plugin.
    This way already connected servoy-clients are not directly aware of the changes you did, after restarting a client they will.

Hope this helps.

databaseManager.recalculate() can be used for a whole foundset as well. So no need to loop.

Thanks to both of you!

In this case, the table has almost 300.000 records.

This works great, thanks again!

var fs = databaseManager.getFoundSet(‘db’,‘table’);
fs.loadAllRecords();
databaseManager.recalculate(fs);


Federico Galluzzo
Area 5578