get record from primary keys

is there a way in which to get a record from a foundset via primary keys without having to select a record?

doing this: foundset.selectRecord is pretty expensive in some forms, and all I would like to do is grab a record to run a recalc on it.

Thanks

Hi Paul,

What about using this code?

// Get a new foundset
var _fs = databaseManager.getFoundSet("serverName","tableName");
// Load the record by it's PK
_fs.loadRecords(databaseManager.convertToDataSet([myIdValue]));
// recalc this record
databaseManager.recalculate(_fs);

Hope this helps.

Thanks for the reply Roclasi,

I don’t think that would work in my scenario, because I am looking to do this for all records affected, which could potentially be slower performance wise with the overhead of the databaseManager function calls.

The other reason I am looking for this functionality is so that I can perform other actions to a record without the overhead of selecting a record.

I can get to a record via index, and select a record via pks, so I thought there would be some way of achieving this.

You are grabbing a record, so Servoy loads the record and thus the calcs are fired. No need to recalculate at all, because Servoy takes care of that for you.

The only time you need to run a recalculation is if you change something of which you know that it affects records with stored calculations that are not loaded into the Clients memory.

And then only when you need the values in the DB to be correct for retrieving them without accessing the records in the Client (which would trigger the calc firing anyway), so only for direct DB access (external or databaseManager.getdatasetByQuery) like reporting tools.

Paul

pbakker:
You are grabbing a record, so Servoy loads the record and thus the calcs are fired. No need to recalculate at all, because Servoy takes care of that for you.

Just for the record…you mean only for unstored calcs, right ? Because if loading a record causes a recalc for stored calcs (and thus a save to the backend) this would be highly undesirable.

No, I really meant Stored Calcs. Why would this be undesirable? I think it’s highly undesirable if it wouldn’t do this, because then the user might be looking at stale data.

Of course the update to the database only happens when the value actually is different, but I assume you already know that.

Paul

I guess it depends on your use cases. In mine I tend to use a method instead of a calc just to be sure it only gets triggered once.