sql - 将带有 Join 的 SQL 查询转换为 X++ Dynamics AX 脚本
问题描述
我有一个不那么简单的 SQL 查询,因为它包含 Join
SELECT *
FROM table1 a inner join table2 b on a.field1 = b.field1
inner join table3 c on a.field2 = c.field2
inner join table4 d on c.field3 = d.field3
inner join table5 e on c.field4 = e.field4
WHERE a.location = 'asia' AND b.modType = 1
and c.discount = 'sample'
and d.name = 'hello'
and e.name in ('one', 'two', 'three')
我喜欢将其转换为 X++ 脚本,这就是我所做的
while select forUpdate
table1 join table2 where table1.field1 == table2.field1
join table3 where table1.field2 == table3.field2
join table4 where table3.field3 == table4.field3
join table5 where table3.category == table5.recid
&& table1.location == 'asia' && table2.modtye == 2
&& table3.discount == 'sample'
&& table4.name == 'hello'
&& table5.name in ('one', 'two', 'three')
我需要检索要更新的数据
但是 x++ 是错误的并且不成功。
希望得到专家的建议,因为我是 X++ scipting 的新手
解决方案
旧版本的 X++ 不支持in运算符。使用|| 反而。
它以此处描述的受限形式受支持,仅支持枚举。
您还需要声明缓冲区:
Table1 table1;
Table2 table2;
Table3 table3;
Table4 table4;
Table5 table5;
while select forUpdate table1
join table2 where table1.field1 == table2.field1
join table3 where table1.field2 == table3.field2
join table4 where table3.field3 == table4.field3
join table5 where table3.category == table5.recid
&& table1.location == 'asia' && table2.modtye == 2
&& table3.discount == 'sample'
&& table4.name == 'hello'
&&(table5.name == 'one' || table5.name == 'two' || table5.name == 'three')
{
info(strFmt('%1 %2 %3', table5.name, table4.name, table3.discount));
}
推荐阅读
- html - 在表格html中将文本与右侧对齐
- excel - DAX 在获取仅包含数字的单元格时计算列的平均值
- javascript - 当文本框不为空或有值时禁用下拉菜单
- r - 将 plyr::ddply 转换为 dplyr
- c# - SendGrid:电子邮件活动 API JSON 响应的反序列化未填充对象
- c# - .NET / C# - 获取下一个半周结束日期
- excel - Excel函数还是工具?查找加起来为指定总和的所有对
- c# - Unity:如何避免将游戏对象拖入公共脚本变量?
- android - TomtomMap.getUserLocation() 总是返回 null?
- django - 允许用户使用 Django Stripe (dj-stripe) 仅使用非付费帐户创建一定数量的对象