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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • Martin Dráb Profile Picture
    237,795 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,565 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
    238 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
    300,904 Super User 2025 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans