Ive never quite seen this behavior before. First of all, this used to work fine and it suddenly stopped working. I have no idea how or why or what changed if anything.
We have two instances of a table, lets call them t1 and t2. We do a while select on t1 with a simple criterion, then inside the while select we set t2 = t1.data then insert t2. To my astonishment, on the next loop of the t1 while select, t1's recid == t2's old recid! So t2 again gets set to t1.data, then gets inserted, then t1 picks up the new record, and so on. Here is the code:
ProdParmStartUp p1 = this.defaultParmBuffer();
ProdParmStartUp p2;
ProdQty startUpQtyRemain;
#OCCRetryCount
if (this.parmId())
{
while select forUpdate p1
order by Linenum
where p1.ParmId == this.parmId()
&& p1.SplitQty > 0
{
ttsBegin;
//Set remaining quantity for each ProdParmStartup
startUpQtyRemain = p1.StartUpQty;
//Update intial ProdParmStartup
p1.StartUpQty = p1.SplitQty;
p1.update();
startUpQtyRemain -= p1.SplitQty;
//Create ProdParmStartup for remaining
while(startUpQtyRemain >= p1.SplitQty)
{
p2.clear();
p2.data(p1);
p2.StartUpQty = p1.SplitQty;
p2.insert();
startUpQtyRemain -= p1.SplitQty;
}
//Create ProdParmStartup for the rest
if(startUpQtyRemain < p1.SplitQty)
{
p2.clear();
p2.data(p1);
p2.StartUpQty = startUpQtyRemain;
p2.insert();
}
ttsCommit;
}
}
*This post is locked for comments
I have the same question (0)