Discussion:
update_recordset is crashing AX...
(too old to reply)
Greg
18 years ago
Permalink
The following method (attached to my table) is causing AX to crash and I
can't figure out why...

void UpdateSelect(NoYesId updateValue)
{
;

update_recordset this
setting NYSelect = updateValue;
}

Now, when I use a standard while select and update the records one at a
time, it works fine. The following code works perfectly and doesn't cause AX
to crash:

void UpdateSelect(NoYesId updateValue)
{
;

ttsbegin;
while select forupdate this
{
this.NYSelect = updateValue;
this.update();
}
ttscommit;
}

This is running on Vista, if that makes a difference. Has anyone seen or
heard of the update_recordset command causing AX to crash?

Thanks
-Greg
unknown
18 years ago
Permalink
"Greg"
...
Greg,

That is IMHO very bad idea to iterate the same table in a table table
function using 'this', regardles of statement used. In my mind it creates
confusion in context.

Table instance methods should do not move the cursor.
If you want to move the cursor, do it outside of table instance metod, for
example in table static method.

Declare yourself another buffer for purpose of your update.

Regards
--
Michal Kupczyk
http://staticsax.blogspot.com/
Greg
18 years ago
Permalink
Hi Michal,

Thank you for the advice on using static methods. I'm pretty new to AX, and
I'm always interested in ways to improve code.

The issue of AX crashing is still occuring, however. I forgot to mention
that the table we are updating is a temporary table. Is that why the
update_recordset function is crashing AX? Is that function only designed for
actual SQL tables?

Thanks
-Greg
...
unknown
18 years ago
Permalink
"Greg"
Post by Greg
Hi Michal,
Thank you for the advice on using static methods. I'm pretty new to AX, and
I'm always interested in ways to improve code.
The issue of AX crashing is still occuring, however. I forgot to mention
that the table we are updating is a temporary table. Is that why the
update_recordset function is crashing AX? Is that function only designed for
actual SQL tables?
The place where using update_recordset gives most benefits are obviously SQL
tables.

For processing ax temporary tables I would expect very little difference
between update_recordset and iterative way, that's why I never tried
update_recordset on temp tables, but it should work anyway.

With temp table you should know that the data resides on side (C/S) where
first insert took place.
Try to fill in contents in 'server static' method, and see if using
update_recordset on that also creates problem.

Repeat same excercise on one of standard temp tables, and you may raise your
first error to MBS :-)
--
Michal Kupczyk
http://staticsax.blogspot.com/
Greg
18 years ago
Permalink
Changing the method to 'server static' instead of just 'static' fixed the
crash issue. I imagine this has to do with where the temp table is created,
though it appears I need to do some more homework on temp tables.

We'll probably just go with an iterative approach for now, since
update_recordset won't give us a significant increase in speed.

Thank you for your help
-Greg
...
Palle Agermark [thy:data]
18 years ago
Permalink
DELETE_FROM, UPDATE_RECORDSET, INSERT_RECORDSET and ARRAY_INSERT all will
only work with SQL tables and not with temporary tables. The Developer Help
in AX has some good articles about this stuff.

But of course, trying to use it on a temporary table should make AX crash.
--
Best Regards,
Palle Agermark
http://www.thydata.dk/?lang=en
http://palleagermark.blogspot.com/
...
unknown
18 years ago
Permalink
Actually, it's working fine, so I would search for errors in your code.

Tested on DAX 3.0 SP5, 4.0 SP1 and SP2
I created a tmp table (Table1) and wrote this job:

static void Job1(Args _args)
{
Table1 table1;
;
table1.Field1 = "BYE";
table1.insert();

while select table1
{
info(table1.Field1);
}

update_recordset table1
setting field1 = "HELLO";

while select table1
{
info(table1.Field1);
}
}

the infolog shows:

bye
hello

The only thing you should keep in mind is that temporary tables are stored
on disk (hard drive), and so are accessed sequencially (record by record).

so bulk operations like update_recordset actually won't add any speed to
your code, as they will be transformed to simple insert() operations.
--
Kashperuk Ivan (Vanya), Dynamics AX MCBMSS
My blog - http://kashperuk.blogspot.com
MorphX IT in Russian - http://www.lulu.com/content/723888
...
Loading...