简体   繁体   中英

How to see the SQL expression of an X++ select statement Pre Ax2012?

I am using Axapta 4.0 and want to see what SQL Statement is generated out of my x++ code.

How can I see the generated SQL Statement ?

Some background so you might understand why I want to see the code. My X++ Sourcecode compiles but during execution I get the message that it can't join the tables because the where clause is wrong (not matching). I looked it up in the AOT and it matches.

I read this how-to-see-the-sql-expression-of-an-x-select-statement but it seems that it only applys to AX2012 and not Axapta4.0

I have the big statement which isn't working here

select *
    FROM ltabInventTable
    join * FROM ltabModelList
        where  ltabModelList.ItemId == ltabInventTable.ItemId
        && ltabModelList.IsAssortment == 0
    join * FROM ltabInventTableModule
        where ltabInventTableModule.ITEMID == ltabInventTable.ITEMID
        && ltabInventTableModule.ModuleType == 1
    join * FROM ltabCharValue
        where ltabCharValue.CHARACTERVALUE == ltabModelList.MODELLCONFIGID
    join * FROM ltabBarcodes
        where ltabBarcodes.ITEMID == ltabInventTable.ITEMID
    join * from ltabInventDim
        where ltabInventDim.INVENTDIMID == ltabBarcodes.InventDimId
    join * FROM ltabConfigTable
        where ltabConfigTable.ITEMID == ltabBarcodes.ITEMID
        && ltabConfigTable.CONFIGID == ltabInventDim.CONFIGID
        && ltabConfigTable.MODELCONFIGID == ltabModelList.MODELLCONFIGID
    outer join ltabPriceDiscItemResult //IN HERE WE HAVE THE PROBLEM
       where ltabPriceDiscItemResult.ITEMID == ltabModelList.ITEMID
        && ltabPriceDiscItemResult.MODELCONFIGID == ltabModelList.MODELLCONFIGID
        && ltabPriceDiscItemResult.SIZEID == ltabModelList.SizeID;

And I have a smaller version which works.

SELECT * FROM ltabModellist //AWESOME THIS WORKS
    outer join ltabPriceDiscItemResult
       where ltabPriceDiscItemResult.ITEMID == ltabModelList.ITEMID
        && ltabPriceDiscItemResult.MODELCONFIGID == ltabModelList.MODELLCONFIGID
        && ltabPriceDiscItemResult.SIZEID == ltabModelList.SizeID;

The smaller version is joining exactly like the bigger one but the bigger one is throwing an error.

Edit:

The error message was requested. The problem is that the error is only in german. i will provide both the german error message and the google translation of it.

Original:

Ein Datensatz in Resultat Preisabschrift (PriceDiscItemResult) kann nicht ausgewählt werden. Der Join enthält in der WHERE-Klausel keine Verknüpfung zwischen den Join-Tabellen.

Google translation:

A record in result pricemarkdown (PriceDiscItemResult) can not be selected. The join in the WHERE clause contains no link between the join tables.

Use Sql profiler to capture the sql statements.

Below blog explains it in details.

Brandon's Dynamics AX SQL Server Profiler Recipe to see the underlying Tables and SQL

To know more about SQL Profiler refer msdn article. SQL Server Profiler

There are some tracing settings in the user options in the AX client on the SQL tab that allow you to log sql statements in various outputs (file, table, infolog). See Tracing with the Tools Menu for more information.

Also the configuration utilities for the server and client have some tracing options (see Set tracing options for more information).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM