I am curious about the SELECTLATESTVERSION function. The help says that this function "forces the latest version of the database to be used". How would it be possible to NOT be using the latest version of the database? I understand that in some cases I need to do appropriate locking to guarantee the latest version of a particular record, but what is the "latest version of the database" that this function seems to be referring to?
What would Elvis do?
0
Comments
For example you have a batch where you load the item Table into and make there some changes. Now, after changeing you want to do a another modify on the recordvariable instance. To get now the latest "version" (and not the datas that you have in xour cache on recordVariable) u can call SelectLatesVersion.
Hope understandable.
Regards
My understanding is that Navision native database uses an historical versioning scheme to accomplish what is done with transaction logging and rollbacks in other databases - sql for instance. I assume that once a record has been changed and becomes commited to the latest historical version in the database any subsequent reads by any users will retrieve the latest version of that record. I don't have to do anything special programming-wise to be sure that the data I read reflects any changes that have been made by other users before my read. If that was not true, Navision would just not work in a multi-user environment.
So I will re-phrase my question a bit: When would it be necessary to use this function instead of just re-reading the record or records that I am interested in? In what kind of situation would I be reading a record from a version in the database that is not the latest?
You would typically use it when a record is retrieved from a 'hot' table (a table with many updates to records), and where there's a lot of checking going on before updating the record, when there is 'a lot of time' between getting the record and actually modifying it, when there might be a chance that someone else modified the record that you retrieved between the time that you retrieved it and the time that you need to update it. Other examples are NAS instances that run for long periods of time, and you'd use it to refresh setup records.
Personally I've always used new GET statement, I always like to be explicit in my code and I think I had an issue with it early on in my career. I don't think there's a lot of use for it on SQL Server, doing a new GET essentially does the same thing.
RIS Plus, LLC
Also, if I was concerned about having the latest version of a record before using or modifying data from said record, I would use locking. Otherwise, in a multi-user environment there would never be any guarantee that what you have is the latest data - even using this function.