Monday, September 10, 2007

Why to call update

Question
This does not updates the table
AssetParameters asset;
;
asset =AssetParameters::find(true);
ttsbegin;
asset.AutoNumber=NoYes;
ttscommit;
------------------------------------------------------------------------------------------------But
the following code updates the table now the question why there is need
of call asset.update(); ------------------------------------------------------------------------------------------------
AssetParameters asset;
;
asset =AssetParameters::find(true);
ttsbegin;
asset.AutoNumber=NoYes;
asset.update();
ttscommit


Answer:
AX works with cursors
In code snippet , asset - is a cursor - a special object storing the values of a record of a specific table, in your case, the AssetParameters table. Which means that you can modify any fields in this cursor, but they won't get reflected in the database, because it's NOT the database, it's just a
storage for the values you input. The update method, if properly called (notice the ttsbegin and commit and the true parameter in the find method), will transfer the changes in the
cursor into the database.DAX kernel makes the analysis and extra manipulations with the data when
super() of this method on table level is called.For example, it can set the modifiedBy and other modified* fields on the record, if the corresponding properties are turned on on the table.
Also, it analyzes the fields that have been changed and creates the query,needed for the update, assigns a new RecVersion, validates that no other users have changed the record while you were making your changes (here concurrency models are analyzed as well), etc...

No comments: