[英]Axapta: “The record has never been selected” error after Group By clause
I'm new in Ax 2009. I would like to update the field of a record in table A after joining with another table B on which I want to apply Group by on its ID.我是 Ax 2009 的新手。在加入另一个表 B 后,我想更新表 A 中记录的字段,我想在其 ID 上应用 Group by。
I tried to run the following code but it throw me an error "Cannot edit a record in tableA. The record has never been selected":我尝试运行以下代码,但它给我一个错误“无法编辑 tableA 中的记录。该记录从未被选中”:
where select forupdate tableA group by tabAid, Dimension[5]
join tableB group by tabBid, Dimension[5]
where tableA.tabAid == tableB.tabBid && tableB.Dimension[5] != "" && tableA.Dimension[5]
{
if(tableA.Dimension[5] != lines.Dimension[5])
{
ttsbegin;
tableA.Dimension[5] = tableB.Dimension[5];
tableA.update()
ttscommit;
}
}
I think it should be caused by the usage of Group By clause on tableA but if i remove it, on the if check, the tableA.Dimension[5] is empty.我认为这应该是由于在 tableA 上使用 Group By 子句引起的,但是如果我将其删除,则在 if 检查中, tableA.Dimension[5] 为空。
Please someone help me.请有人帮助我。 Thank you.
谢谢你。
Yes, the problems are the Group by
clauses.是的,问题是
Group by
子句。 Try something like this.尝试这样的事情。
ttsbegin;
while select forupdate tableA where tableA.Dimension[5] != ""
join tableB where tableB.tabBid == tableA.tabAid && tableB.Dimension[5] != ""
{
if(tableA.Dimension[5] != tableB.Dimension[5])
{
tableA.Dimension[5] = tableB.Dimension[5];
tableA.update()
}
}
ttscommit;
*I made the code without compiler, maybe it needs some adjustment. *我在没有编译器的情况下编写了代码,可能需要一些调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.