Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Comparisons...

Comparisons...

Scheduled Pinned Locked Moved The Weird and The Wonderful
career
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jan larsen
    wrote on last edited by
    #1

    Found an interesting feature in Microsoft Dynamics Ax 2012 R2:

    static void Job40(Args _args)
    {
    smmBusRelTable bus;
    int i;

    select count(RecId) from bus where
        bus.BusRelAccount == bus.TopLevelAccount
    ;
    
    info(strFmt("From count: %1", bus.RecId));
    
    i = 0;
    while select bus where
        bus.BusRelAccount == bus.TopLevelAccount
    {
        i++;
    }
    
    info(strFmt("bus.BusRelAccount == bus.TopLevelAccount: %1", i));
    
    i = 0;
    while select bus where
        bus.TopLevelAccount == bus.BusRelAccount
    {
        i++;
    }
    
    info(strFmt("bus.TopLevelAccount == bus.BusRelAccount: %1", i));
    

    }

    Running the job results in this output:

    From count: 31597
    bus.BusRelAccount == bus.TopLevelAccount: 1
    bus.TopLevelAccount == bus.BusRelAccount: 31597

    :omg:

    "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr

    B 1 Reply Last reply
    0
    • J jan larsen

      Found an interesting feature in Microsoft Dynamics Ax 2012 R2:

      static void Job40(Args _args)
      {
      smmBusRelTable bus;
      int i;

      select count(RecId) from bus where
          bus.BusRelAccount == bus.TopLevelAccount
      ;
      
      info(strFmt("From count: %1", bus.RecId));
      
      i = 0;
      while select bus where
          bus.BusRelAccount == bus.TopLevelAccount
      {
          i++;
      }
      
      info(strFmt("bus.BusRelAccount == bus.TopLevelAccount: %1", i));
      
      i = 0;
      while select bus where
          bus.TopLevelAccount == bus.BusRelAccount
      {
          i++;
      }
      
      info(strFmt("bus.TopLevelAccount == bus.BusRelAccount: %1", i));
      

      }

      Running the job results in this output:

      From count: 31597
      bus.BusRelAccount == bus.TopLevelAccount: 1
      bus.TopLevelAccount == bus.BusRelAccount: 31597

      :omg:

      "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr

      B Offline
      B Offline
      Bernhard Hiller
      wrote on last edited by
      #2

      A badly designed operator override? At least fun to see that (bus.BusRelAccount == bus.TopLevelAccount) != (bus.TopLevelAccount == bus.BusRelAccount)

      J 1 Reply Last reply
      0
      • B Bernhard Hiller

        A badly designed operator override? At least fun to see that (bus.BusRelAccount == bus.TopLevelAccount) != (bus.TopLevelAccount == bus.BusRelAccount)

        J Offline
        J Offline
        jan larsen
        wrote on last edited by
        #3

        I wish it was that easy. But X++ does not have overrides, the Dynamics Ax VM creates SQL statements from this code. By tracing statements in the SQL Server I may be able to see the different statements created, but the bottom line is, that this should be a very very simple comparison, and having a failure here, gives me the creeps.

        "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr

        B 1 Reply Last reply
        0
        • J jan larsen

          I wish it was that easy. But X++ does not have overrides, the Dynamics Ax VM creates SQL statements from this code. By tracing statements in the SQL Server I may be able to see the different statements created, but the bottom line is, that this should be a very very simple comparison, and having a failure here, gives me the creeps.

          "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr

          B Offline
          B Offline
          Bernhard Hiller
          wrote on last edited by
          #4

          Ah, I see. Reminds me of an old "obfuscted" Access database, where

          SELECT * FROM A, B where A.ID=B.A_ID

          was different from

          SELECT * FROM A JOIN B ON A.ID=B.A_ID

          The trick was that in one case padding with spaces was relevant, in the other case not.

          J 1 Reply Last reply
          0
          • B Bernhard Hiller

            Ah, I see. Reminds me of an old "obfuscted" Access database, where

            SELECT * FROM A, B where A.ID=B.A_ID

            was different from

            SELECT * FROM A JOIN B ON A.ID=B.A_ID

            The trick was that in one case padding with spaces was relevant, in the other case not.

            J Offline
            J Offline
            jan larsen
            wrote on last edited by
            #5

            Ha! I found the problem. DAX uses a caching mechanism to avoid too many roundtrips to the SQL Server. If you're using the primary key in a query, then DAX will search an in-memory cache to retrieve a single record. Apparently, DAX gets confused when I use the primary key field busRelAccount on the left hand side of the comparison. Using bus.disableCache(true) fixes this problem. I hope they get rid of this bug soon, I really don't like to think of all the places I could have trusted this to just work.

            "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups