Announcements
Hi,
any known issues about this?
I've encountered a custom method which tries to update a set of record by joining 2 tables with the update_recordset statement. Something like:
update_recordset myTable1
setting [fieldsList]
join myTable2
where [conditions]
The instruction returns this error "could not update a record" and i can see this join doesn't retrieves anything.
If i do the same with a "while select forUpdate" statement, it works fine. The records are retrieved and updated.
Obviously this takes much more time than the update_recordset.
Any idea about this issue?
Thank you in advance
*This post is locked for comments
The error message is in italian. I've tried to look for it in the label editor, but could not find the exact entry.
But it is something like "could not update a record in table %1 .... SQL database error"
Yes guys, it seems that the division by zero throws that error on the update_recordSet statement.
update_recordset myTable1
setting numericField/divisionField
join myTable2
where [conditions]
if divisionField equals zero, Ax returns the following:
Cannot edit a record in myTable1 (myTable1Name). [...] SQLdatabase error.
Divisiobn by zero obviously is a problem. Please do the check before even trying to run your query.
First of all, try setting a fixed value (setting RevisionSalesQty = 42). If it works, use the field from the child record (setting RevisionSalesQty = revLine.RevisionPercent). If it works, add the expression (/revPercentDiv). That should give you a better idea what exactly doesn't work; trying to debug many things at once usually doesn't bring any result at all. I'm not sure that the last case is supported by update_recordset.
Also, can you give us the error message?
I've "translated" this update_recordSet into the while select below.
The value "revLine.RevisionPercent/revPercentDiv" previously led to "division by zero" error inside the select while. Could be that the cause?
Anyway, the update_recordSet was not retrieving anything...
update_recordset salesLine_update
setting RevisionSalesQty = revLine.RevisionPercent/revPercentDiv
join revLine
where !revLine.SalesId &&
revLine.ItemGroupId == salesLine_update.ItemGroupId &&
revLine.RevisionId == RevisionId &&
salesLine_update.Runnumber == RSRun_loc.Runnumber;
//This one works fine
while select forUpdate salesLine_update
join revLine
where !revLine.SalesId &&
revLine.ItemGroupId == salesLine_update.ItemGroupId &&
revLine.RevisionId == RevisionId &&
salesLine_update.Runnumber == RSRun_loc.Runnumber
{
if(revPercentDiv!=0)
RevisionSalesQty = revLine.RevisionPercent/revPercentDiv;
}
Hi win32,
Please share your actual code which is working for while select statement and not with update_recordset then we will be able to find the exact missing point from there. For your reference I am sharing a small concept on update_recordset, it may help you but important to share your code.
Can you show us your actual code and copy the exact wording of the error message, please?
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156