Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

Strange behavior from inMemory tables when grouping

Posted on by 1,665

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

  • BrandonSA Profile Picture
    BrandonSA 1,665 on at
    RE: Strange behavior from inMemory tables when grouping

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

  • Martin Dráb Profile Picture
    Martin Dráb 225,490 Super User on at
    RE: Strange behavior from inMemory tables when grouping

    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
    BrandonSA 1,665 on at
    RE: Strange behavior from inMemory tables when grouping

    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
    Martin Dráb 225,490 Super User on at
    RE: Strange behavior from inMemory tables when grouping

    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
    BrandonSA 1,665 on at
    RE: Strange behavior from inMemory tables when grouping

    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
    Martin Dráb 225,490 Super User on at
    RE: Strange behavior from inMemory tables when grouping

    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?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans