Temporary table in AOT query

Hi all!

I need to set temporary table as data source in AOT query. I have created a query in AOT, data source is temporary table and the query has only one data source. So, my question is How I can use this query? Before running my query I populate temporary table with data. But how can I connect data source of query with new created instance of temporary table?

Any suggestions are welcome!


See here for examples of temporary table uses with queries:


Hi Alex!

Thank you for reply, but there is nothing related with AOT query. There is only examples of using temporary table in forms and in reports.

Set the temporary buffer using QueryRun.setCursor() method.

Hi Martin!

Thank you very much for your answer, now my query is working.


please can you explain more the solution.i faced the same problem.where should i populate temporary table with data ?and how Set the temporary buffer using QueryRun.setCursor() method.

Thanks Sir,

I have the same problem, I’ve created a TempDB table, then in the init method of the AOT query I’m inserting records to this temporary table and the using this.setRecord(MyTempDBTable) or this.setCursor(MyTempDBTable), but I get nothing on the form. I know that the table instance gets erased once the init method finishes, but it should copy the records when I call setRecord or setCursor, does anyone know how to do this?

Your question is very different from what was discussed in this thread four years ago.
Anyway, what you need is linkPhysicalTableInstance().

Thanks Martin!

The reason I need queries is because I’m building a workspace in AX7 with summary Count Tiles, and for some unknown reason the Count Tiles do not support queries with aggregates (sum, avg, etc. and group by’s - it generates an error in runtime), so I need to run an X++ SQL statement and then populate the TempDB table. So what I was planning on doing was to create a query with the TempDB as a datasource, and then from the init method of the query populate that TempDB table and then using the setRecord method update the query. But this approach does not seem to work at all. I will use a regular table instead in the query.