RE: Update conflict error
Hi Hari,
Following error you get if you have following scenario,
Static void NIT_update1(Args _args)
{
NIT_SKUTable SKUTable1;
NIT_SKUTable SKUTable2;
ttsBegin;
select forupdate SKUTable1 where SKUTable1.SKUID == 1;
//do something
ttsBegin;
select forupdate SKUTable2 where SKUTable2.SKUID == 1;
SKUTable2.Qty = 50;
SKUTable2.update();
// do something more
ttsCommit;
// do something more and more
SKUTable1.Qty = 60;
SKUTable1.update();
ttsCommit;
}
to avoid error you need to write following code
Static void NIT_update2(Args _args)
{
NIT_SKUTable SKUTable1;
NIT_SKUTable SKUTable2;
ttsBegin;
//do something
ttsBegin;
select forupdate SKUTable2 where SKUTable2.SKUID == 1;
SKUTable2.Qty = 50;
SKUTable2.update();
// do something more
ttsCommit;
// do something more and more
select forupdate SKUTable1 where SKUTable1.SKUID == 1;
SKUTable1.Qty = 60;
SKUTable1.update();
ttsCommit;
}
So moral of the story is,
when implementing logic in SQL transaction, create the transaction with atomicity
that is, Select the record for update just before calling table update() method.
Please try to investigate your customization, may be you will also have same scenario.
Please verify.