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

Strange behavior from inMemory tables when grouping

(0) ShareShare
ReportReport
Posted on by 1,673

Hi everyone

I just learnt about some strange behaviour from AX that occurs when you group on inMemory tables.

If I say

MyTable t;

select ColA from t group by ColA;
print t.ColB;

then naturally, ColB is null if MyTable is a regular or tempDB table because it isn't part of the field list, nor is it being grouped on which means it's truncated, but strangely, ColB has a value if MyTable is inMemory.
I know these table types are stored differently between the AOS and SQL depending on what type they are, but is this behaviour a bug or a feature?
If it's a feature, what are the rules for what value ColB gets and is there any documentation for it? Does ColB just get the first value for each group of ColA?

Any thoughts appreciated. Tx

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

    I've never seen such a problem with InMemory tables.

    Your code snippet seems to print ColB variable, not t.ColB field. Is your actual code correct? Can you please give us an example that we could run, using a standard temporary table? For example, you could use TmpSearchResult table, if it exists in AX 2012 (I can't be sure because I'm on F&O).

    What value do you see in the field?

  • BrandonSA Profile Picture
    1,673 on at

    Hi Martin

    Thank you for the reply. I did have a typo in my post, omitting t when printing ColB - I've updated my post to correct it.

    I just set the scenario up in Ax and ran it. Here is the result: (MyTable is inMemory)

    pastedimage1683759942990v1.png

    Ax Version is Ax 2012 R2 CU7

    PS. Interestingly, I just ran the same job in F&O (10.0.33) and still get the same behavior:

    pastedimage1683761915000v1.png

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

    Interesting. I'm not sure if I can find much about how the kernel handles it, but I'll try. Could you please share your code, so everyone doesn't have to type it again?

  • BrandonSA Profile Picture
    1,673 on at

    Sure. Thank you Martin

    static client void Job49(Args _args)
    {
       MyTable t;

       void insert(str a, str b)
       {
           t.initValue();
           t.ColA = a;
           t.ColB = b;
           t.insert();
       }

       insert('Alpha', 'One');
       insert('Gamma', 'Two');
       insert('Alpha', 'Three');
       insert('Beta', 'Four');

       while select ColA from t group by ColA
       {
           info(strFmt('%1 %2', t.ColA, t.ColB));
       }
    }

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

    All I can say is that I see the same behavior as you. It looks wrong to me and I have no explanation for it.

  • BrandonSA Profile Picture
    1,673 on at

    Thanks Martin for looking into it, it is a very strange error

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans