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 :
Microsoft Dynamics AX (Archived)

Using insert recordset in temporary table

(0) ShareShare
ReportReport
Posted on by 239

I have created two instance of single temporary table eg: table1 and table2,

First i filled table1 data and then,

I am trying to insert table1 data into table2 using insert_recordset through following code

insert_recordset table2 (field1,field2)

select field1,field2 from table 2;

But it when debugger comes to execution of this statement, AX doesn't respond and have to restart.

What could be the problem...? 

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    I tried to simulate the problem and it all works all right on my system.

    Can you please show us full code needed to reproduce the problem? Of course, please cut off everything not related to this issue.

  • kartik0603 Profile Picture
    239 on at

    private void printType()

    {

       if(contract.parmOriginal())

       {

               this.insertRecordSet('Original Print')

       }

    }

    private void insertRecordSet(Name _printType)

    {

    insert_recordset(InvoiceId,PrintType)

            select InvoiceId,_printType

                  from custInvoiceJour;

    }

    I have to insert the value of parameter in field 'PrintType'

    Same way i have different conditions as a parameter.

  • Martin Dráb Profile Picture
    237,807 Most Valuable Professional on at

    Sorry, it's nothing I could run to see your problem. I also don't see how you're initializing the tables. Furthermore, the content of insertRecordSet() isn't valid X++ code. Please give us real code.

  • Ali Zaidi Profile Picture
    4,657 on at

    Some times this type of error occurs, You can restart the AOS service and connect the Client again.  Hopes this works.

  • Suggested answer
    Amir Nazim Profile Picture
    5,994 on at
  • Volodya Profile Picture
    on at

    Hello,

    I have the same issue: DAX 2012 R2 is hanged when tempDB table is used in the insert_recordset bulk operation.

    Since there is no Query::insertRecordSet method in R2 i try to mimic dynamic filter by populating the tmpMainAccount tempDB table with selected main accounts (Dialog uses the Main account filter with multilookup)

    The code is here, do you know any workarounds?:

        StartDate                           startDate;
        EndDate                             endDate;
        MainAccountNum                      mainAccountId;
        DimensionValue                      location;
    
        LedgerParameters                    ledgerParameters = LedgerParameters::find();
        Name                                dimensionAttributeLocationName = /*ledgerParameters.FRNLocationDim ? ledgerParameters.FRNLocationDim :*/ 'Locations';
        DimensionAttribute                  dimensionAttributeLocation = DimensionAttribute::findByLocalizedName(dimensionAttributeLocationName);
    
        FRNTmpDimValue                      tmpMainAccount;
        FRNTmpDimValue                      tmpLocationDim;
        DimensionFinancialTag               dimensionFinancialTag;
        LedgerJournalTrans                  ledgerJournalTrans;
        LedgerJournalTrans                  ledgerJournalTransOffset;
        DimensionAttributeValueCombination  dimensionAttributeValueCombination;
        VendTable                           vendTable;
        DirPartyTable                       dirPartyTable;
        DimensionAttributeValueCombination  dimensionAttributeValueCombinationOffset;
        DimensionAttributeLevelValueView    dimensionAttributeLevelValueView;
        LedgerJournalTable                  ledgerJournalTable;
    
        // Set the userconnection to use on table.
        // This is required to ensure that createdTransactionId of inserted record is different than default transaction.
        this.takeOwnershipOfTempTable(vouchersDashboardTrans);
    
        contract    = this.parmDataContract() as FRNVouchersDashboardDataExportContract;
    
        startDate   = contract.parmStartDate();
        endDate     = contract.parmEndDate();
        mainAccountId = contract.parmMainAccountId();
        location    = contract.parmLocationDimensionValue();
    
        this.populateMainAccount(tmpMainAccount, mainAccountId);
    
        this.populateDimensionValue(tmpLocationDim, dimensionAttributeLocation, location);
    
        this.parmUserConnection().ttsbegin();
    
        insert_recordset vouchersDashboardTrans (AmountCurCredit, DocumentDate, VendorName)
        select AmountCurCredit, DocumentDate from ledgerJournalTrans
            where  ledgerJournalTrans.AccountType       == LedgerJournalACType::Vend
                && ledgerJournalTrans.AmountCurCredit   != 0
                && (startDate == dateNull() || ledgerJournalTrans.DocumentDate >= startDate)
                && (endDate == dateNull() || ledgerJournalTrans.DocumentDate <= endDate)
        join dimensionAttributeValueCombination
            where dimensionAttributeValueCombination.RecId == ledgerJournalTrans.LedgerDimension
        join vendTable
            where vendTable.AccountNum == dimensionAttributeValueCombination.DisplayValue
        join Name from dirPartyTable
            where dirPartyTable.RecId == vendTable.Party
        join dimensionAttributeValueCombinationOffset
            where dimensionAttributeValueCombinationOffset.RecId == ledgerJournalTrans.OffsetLedgerDimension
        exists join tmpMainAccount
            where tmpMainAccount.Key == dimensionAttributeValueCombinationOffset.MainAccount;


    PS: insert_recordset works correctly without the tmpMainAccount exists join.

  • tgudwanski Profile Picture
    32 on at

    I've experienced a very similar issue while creating data provider class for one of the SSRS reports.

    I've needed a number of temporary tables to quickly transform some portions of warehouse transactions data but after report execution, Ax Client hanged.

    What helped to solve the issue was to set the same connection for all the tables: temporary and regular which were used in insert_recordset  bulk queries.

    Below is a little code sample:

    if (this.parmUserConnection()) 
    { 
        (...) 
    
        temporaryTable1.setConnection(this.parmUserConnection()); 
        temporaryTable2.setConnection(this.parmUserConnection()); 
    
        inventTrans.setConnection(this.parmUserConnection()); 
        inventTransOrigin.setConnection(this.parmUserConnection()); 
    
        (...) 
    }

    The this.parmUserConnection() object was connection object provided by SSRS data provider base class, but may be somehow all of this could be helpful in your scenario.

    Please consider also all the previously posted suggestions since I think you might find them helpful for your case.

  • Volodya Profile Picture
    on at

    Thank you it works for me!

    I've added the following line of code:

        this.takeOwnershipOfTempTable(vouchersDashboardTrans);
        this.takeOwnershipOfTempTable(tmpMainAccount);
    


    So it seems all tempDB tables should use the same connection.

  • tgudwanski Profile Picture
    32 on at

    I'm really glad it helped :)

    Regards.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans