Skip to main content

Notifications

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

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,031 Super User 2025 Season 1 on at
    RE: How to use TempDB as Data Source

    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.

  • Ferhat.S Profile Picture
    Ferhat.S 236 on at
    RE: How to use TempDB as Data Source

    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

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: How to use TempDB as Data Source

    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.

  • Martin Dráb Profile Picture
    Martin Dráb 230,868 Most Valuable Professional on at
    RE: How to use TempDB as Data Source

    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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,031 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,868 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans