Announcements
No record found.
what is the difference between select forupdate tablebuffer; statement and tablebuffer.selectforupdate() in AX 2012?
*This post is locked for comments
Hi Surendra Konatham
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
Surendra,
it all depends on your implementation.
May be you want to fetch data from table and then put an if condition on some records if you want to update the particular record.
e.g.
Select * from table; if(table.RecId) { if(table.value == "Xyz") { table.selectforupdate(true); //perform update } else { //perform your logic } }
Mark answer as verified if it helps.
Thank u
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 do not reselect the record.
Here is how the bestpratice 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 didnt know about how to make a find method and why:https://msdn.microsoft.com/en-us/library/aa879893.aspx
https://msdn.microsoft.com/en-us/library/aa672421.aspx
/Erling Damsgaard
Optimate, D365 Developer since Atlanta (code name for AX in 1997)
Hi Surendra,
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.
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.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Joris dG 5
Alexey Lekanov 2
Henrik Nordlöf 2 User Group Leader