Hello,
I have weird problem when using direct SQL and AOT Query from X++ code in my AX 2009 Application.
My SQL is like below and I thing it returns rigth result but when using AOT Query object where Ranges and Relations are defined exaclty same as in pure SQL returns different count of rows. Can anyone give a hint why this occurs?
Br
Michael
// Pure SQL
str dataarea = "tk"; str accountnum = "4015"; str moduletype = "2"; str unitid = "kpl"; str querySQL = strfmt( "SELECT InventTableModule.UnitId, custtable.AccountNum, custTable.Name, " + "custtable.dataareaid, " + "priceDiscTable.Percent1, priceDiscTable.Percent2, inventTable.Itemid, " + " inventTable.ItemName " + "FROM CustTable, PriceDiscTable, InventTable, InventTableModule where " + "CustTable.AccountNum = PriceDiscTable.AccountRelation and " + "PriceDiscTable.ItemRelation = InventTable.ItemId and " + "InventTable.ItemId = InventTableModule.ItemId and " + "custtable.dataareaid = '%1' and " + "CustTable.AccountNum = '%2' and " + "InventTableModule.ModuleType = '%3' and " + "InventTableModule.UnitId = '%4'", dataarea, accountnum, moduletype, unitid); permission = new SqlStatementExecutePermission(querySQL); Con = new Connection(); permission = new SqlStatementExecutePermission(querySQL); permission.assert(); Stmt = Con.createStatement(); R = Stmt.executeQuery(querySQL);
// Versus AOT Query object where tables are define hierarchial way with Ranges and Relations
CustTable PriceDiscTable InventTable InventTableModule