Yongquan
Yongquan

Reputation: 58

AX2012 (X++) why using multiple instances for same table?

I'm pretty new to X++ and I got a question when reading some old code for AX2012 which was done by someone I don't know.

MyTable mytable1
MyTable mytable2
Mytable mytable3

ttsBegin;
   while select forUpdate * from mytable1 ....
   {...}
   while select forUpdate * from mytable2 ....
   {...}
   while select forUpdate * from mytable3 ....
   {...}
ttsCommit;

My question is why here it is using multiple instances of the same table? what is the benefit of doing so?

thanks,

Upvotes: 0

Views: 399

Answers (1)

Jonathan Bravetti
Jonathan Bravetti

Reputation: 2238

There is no benefit. It is the same using a single variable of that table.

For example, this is the same:

MyTable mytable1

ttsBegin;
while select forUpdate * from mytable1 ....
{...}
while select forUpdate * from mytable1 ....
{...}
while select forUpdate * from mytable1 ....
{...}
ttsCommit;

Election of the "artist". Perhaps the developer that perform this code understand better the code using 3 variables at the same table and not just 1.

Upvotes: 3

Related Questions