General X++ Development
How do I get the SQL statement generated by an X++ query?
How do I get the SQL statement generated by an X++ query?
1 answer
Write an answerFor a Query object, call getSQLStatement() on the query itself.
Query query = new Query();
QueryBuildDataSource qbds;
qbds = query.addDataSource(tableNum(CustTable));
qbds.addRange(fieldNum(CustTable, AccountNum))
.value(queryValue('US-001'));
info(query.getSQLStatement());I use this when a dynamic query is not returning what I expect. Instead of guessing what the query framework built, look at the SQL it generated.
If you are debugging a normal X++ select instead of a Query object, use generateOnly and call getSQLStatement() on the table buffer. That is a different pattern and worth knowing too.
Know the solution?
Sign in to contribute an answer and build your community reputation.
Sign in to answer