General X++ Development

How do I use a temporary table in X++?

Asked by Sunny Vasty· Aug 13, 2026· 1 answers

How do I use a temporary table in X++?

SSunny Vasty75 reputation · answered Aug 13, 2026

Populate a temp table buffer the same basic way you populate a normal table buffer.

X++
MyTempTable.clear();
MyTempTable.ItemId = 'A0001';
MyTempTable.Qty    = 10;
MyTempTable.insert();

The part that usually matters is how the temp-table instance is shared.

For TempDB, use linkPhysicalTableInstance() when another buffer needs to point to the same physical temp table.

For InMemory, setTmpData() is commonly used when another buffer needs the same temporary dataset.

If two callers accidentally use different temp instances, the code can look completely correct while one side sees zero rows.