web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to use TempDB as Data Source

(0) ShareShare
ReportReport
Posted on by 28

Dear All,

I hope I am asking the question in the right Forum. 

I have 2 TempDB tables 

CBLTblSchedDataSaleTmp    CBLTblSchedDataSale;
CBLTblSchedDataTemp       _CBLTblSchedDataTemp;

I have inserted some data in _CBLTblSchedDataTemp and I want to use the data, apply some query and write data to another TempDB,  CBLTblSchedDataSale. Extract from my code is as follows

[SrsReportDataSetAttribute(tableStr(CBLTblSchedDataSaleTmp))]
public CBLTblSchedDataSaleTmp Get_CBLTblSchedDataSaleTmp()
{
select CBLTblSchedDataSale;
return CBLTblSchedDataSale;
}

[SrsReportDataSetAttribute(tableStr(CBLTblSchedDataTemp))]
public CBLTblSchedDataTemp Get_CBLTblSchedDataTemp()
{
select _CBLTblSchedDataTemp;
return _CBLTblSchedDataTemp;
}

public void processReport()
{
_Contract=this.parmDataContract() as CBLClsSchedDataContract;
_PRODID=_Contract.prodID();

while
select sum(QtyOrdered), SLD_SALESORDER
from _CBLTblSchedDataTemp
group by SLD_SALESORDER

join _InventDim
where _salesLine.InventDimId==_InventDim.inventDimId

join SizeId, DropId
from _SizeChart
group by SizeId,DropID
where _SizeChart.InventSizeId==_InventDim.InventSizeId

join _ItemData
where _ItemData.ItemId==_salesLine.ItemId
&& _SizeChart.SizeChartId==_ItemData.SizeChartId
{
CBLTblSchedDataSale.SLD_SALESORDER=_CBLTblSchedDataTemp.SLD_SALESORDER;
CBLTblSchedDataSale.QtyOrdered=_CBLTblSchedDataTemp.QtyOrdered;
CBLTblSchedDataSale.SizeID=_CBLTblSchedDataTemp.SizeID;
CBLTblSchedDataSale.DropID=_CBLTblSchedDataTemp.DropID;
CBLTblSchedDataSale.insert();
}

}

The highlighted part is skipped after reading the While Select statement. Help Required

  • Martin Dráb Profile Picture
    241,501 Most Valuable Professional on at

    It's not clear to me what you mean by "The highlighted part is skipped after reading the While Select statement". Please elaborate.

    By the way, your code will be easier to read if you include line indentation. I strongly recommend using Insert > Code (in the rich-formatting view).

    I moved your question from Dynamics AX forum and changed the category to Development / Customization / SDK.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi, If I understood correctly, the code in while select condition does not run and gets skipped. If yes, then either one more more conditions in your code is not correct or you don't have related data. It will be easier to create SQL script, check the data and manipulate the sql script to ensure no issues in query.

  • Ferhat.S Profile Picture
    244 on at

    Hey Tayyab,

    As i understand from "The highlighted part is skipped after reading the While Select statement."  you mean your while select statement is empty. I cant see where you filled your _CBLTblSchedDataTemp table. If you are using temp table and filling them another code or scope they are referencing totaly diffrent datas. Make sure you pass filled temp table to data provider class.

    Maybe this one helps your problem : learn.microsoft.com/.../temporary-tempdb-tables

  • André Arnaud de Calavon Profile Picture
    307,842 Super User 2026 Season 2 on at

    Hi Tayyab,

    As mentioned above, there would be no data retrieved based on all the joins and where-clauses. You can use the debugger to check which parameters or variables don't have the correct value to retrieve the data, or like Mohit mentioned try the query in SQL first.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 532 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 351 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 195

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans