Notifications
Announcements
No record found.
Hi all
Can you please let me know what is the difference between "for update' and "selectforupdate" ?.
Please give me more shed on this.
Thanks!
*This post is locked for comments
I suggest read this last entry on this by the 'man; himself"
https://community.dynamics.com/ax/f/33/t/264453 I have reproduced it here:
The selectForUpdate(..) method is used to set a property on the buffer, so that next time a select is performed the record is locked (if selectForUpdate(true) is used). The method does not reselect the record.
Here is how the best pratice find method should be created on a table:
static InventTable find(ItemIditemId, boolean update = false) { InventTable inventTable; inventTable.selectForUpdate(update); if (itemId) { select firstonly inventTable index hint ItemIdx where inventTable.itemId == itemId; } return inventTable; }
Please see the documentation for AX/Dynamics 365:
https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-ref/xpp-data-query#transactional-integrity
If you didn't know about how to make a find method and why then read:https://msdn.microsoft.com/en-us/library/aa879893.aspx
https://msdn.microsoft.com/en-us/library/aa672421.aspx
There are lot of different posts on this topic on different sites so be careful what you read.
selectForUpdate Method return true or false
https://msdn.microsoft.com/en-us/library/xrecord.selectforupdate.aspx
and select for update table buffer, selects records for update only. Depending on the underlying database, the records might be locked for other users
docs.microsoft.com/.../xpp-data-query
Hi,
You can use SQL statements, either interactively or within source code, to access and retrieve data that is stored in the database. You use the following statements for data manipulation:
select – Select the data to modify.
insert – Add one or more new records to a table.
update – Modify data in existing table records.
delete – Remove existing records from a table.
Before any data can be changed, you must use a select statement to select the data to update. The select forUpdate command selects records for update only. The insert, update, and delete statements perform operations on one record at a time. The array insert, insert_recordset, RecordInsertList, and update_recordset statements perform operations on multiple records at the same time.
Regards Hossein
Thanks Hossein
My question is
1. ttsbegin;
while select forupdate <Table name>
where condition...
{
<Table.update() OR Table.doUpdate();>
}
ttscommit;
2. table.selectforupdate(true)
Both are same ?
please give me more shed on this.
In update() values stored in buffer then update the record with reference to RecID & doupdate() can directly update the record with out cheking the condisions and all.
if we want to select particular record with some conditons....then we use update() method.but In some situation we didn't need to chek the condition,in that situation we use DoUpdate().
In fact,
The doUpdate table method updates the current record with the contents of the buffer. This method also updates the appropriate system fields.
The doUpdate method should be used when the update method on the table is to be bypassed. Suppose you have overridden the update method of the table but sometime there is a situation when you don't want the code written in the overridden update method to be executed and at the same time want any selected record of that table to be updated. In such situation you should call the table.doupdate() method instead of table.update() method.
You mentioned the difference between update() and do update () but I wants to know the exact difference between
And
table.selectforupdate(true);
Is't both are same statement?
If you specify while select forupdate then you don't have to specify again in the loop like table.selectForupdate() as you are already selecting it forupdate in a while statement.
No Sukrut
I am not telling that I want to use both statement in one statement.
I know both are different statements and we can use it only 1at a time.
My question is when to select which statement ? Is there any specific criteria?
You can mark a buffer for update and then do a select:
myTable.selectForUpdate(true); select myTable;
Or you can combine the same thing into a single statement:
select forUpdate myTable;
We usually use the shorter variant, but sometimes you need something else, e.g. if you want to select for update conditionally:
myTable.selectForUpdate(_update); select myTable;
You can see the last case in find() methods, for instance.
Thanks Martin
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2