Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Odd exception occurs trying to retrieve records from query

Posted on by 30

Hi,

I have created an AX job to test an AX query. The query I'm trying to test is AxdPurchaseRequisition. Actually, I have disabled a number of datasources in the query. I only keep 3 data sources enabled.

  • VendPurchOrderJour
  • PurchTableAllVersions
  • PurchLineAllVersions

QueryDatasources.PNG

For these datasources the FetchMode propery is set to "1:n", the JoinMode property is set to "OuterJoin".

The job code looks like this

    Query q = new Query(queryStr(AxdPurchaseRequisition));
    QueryRun qr;
    Common vpoj;
    Common ptav;
    Common plav;

    QueryBuildDataSource qbds_vpoj;
    QueryBuildRange qbr_vpoj_purchid;

    qbds_vpoj = q.dataSourceName("VendPurchOrderJour");

    qbr_vpoj_purchid = qbds_vpoj.addRange(fieldNum(VendPurchOrderJour, PurchId));
    qbr_vpoj_purchid.value(queryValue("2100002142"));

    qr = new QueryRun(q);

    while (qr.next())
    {
        vpoj = qr.get(tableName2Id("VENDPURCHORDERJOUR"));
        ptav = qr.get(tableName2Id("PURCHTABLEALLVERSIONS"));
        plav = qr.get(tableName2Id("PURCHLINEALLVERSIONS"));

        info(strFmt("vpoj recid = %1 > ptav recid = %2 > plav recid = %3", vpoj.RecId, ptav.RecId, plav.RecId));
    }

When I run this code, an exception immediately occurs when following line of code is executed.

while (qr.next())

Cannot select a record in Purchase order confirmations (VendPurchOrderJour).

InMemory temporary tables must be the outer tables when they are joined to a TempDB table or permanent table.

I am not aware of any InMemory temporary table in this query.

What could be the problem here?

Thanks,

Frederiek

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Odd exception occurs trying to retrieve records from query

    Yes, probably.

    I would need to know what exactly you did to identify the actual cause. But it seems you don't need it anymore...

  • Frederiek Profile Picture
    Frederiek 30 on at
    RE: Odd exception occurs trying to retrieve records from query

    Assuming that would have been the problem, then what does the tooltip text on the data source property Enabled mean?

    Specifies whether the data source (and all embedded data sources) should be ignored.

    I would think "embedded data sources" is referring to the child data sources. Or not?

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Odd exception occurs trying to retrieve records from query

    It sounds like if you disabled a parent of an enabled data source.

  • Frederiek Profile Picture
    Frederiek 30 on at
    RE: Odd exception occurs trying to retrieve records from query

    Data sources have the "Enabled" property. To disable the other data sources,  in the AOT, I set the Enabled property to "No" for each of those data sources.

    I am currently unable to reproduce the problem. The query has been modified, and potentially the problem was triggered by disabling one of the data sources which are currently not included in the query. I will see if I ever run into this problem again. If so, I might update this thread.

    Thanks

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Odd exception occurs trying to retrieve records from query

    How exactly did you "disable" the data sources?

    Also, why don't you try to identify the problematic data source? Just knowing that it's related to unknown one of the disabled data sources isn't that useful. Then review where this data source is located (in the structure of the query).

  • Frederiek Profile Picture
    Frederiek 30 on at
    RE: Odd exception occurs trying to retrieve records from query

    It doesn't look like the problem would be security related. The error message appears after disabling the other data sources in the query. If all data sources in the query are enabled, the query runs without any error message.

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Odd exception occurs trying to retrieve records from query

    Can't any of the joined tables be disabled by a configuration key?

    By the way, there is a better way for getting table ID. Use tableNum(VendPurchOrderJour) instead of tableName2Id("VENDPURCHORDERJOUR").

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans