baanconsultant
19th May 2005, 13:07
Hi,

I have a dal on a table with years and turnover for every year and customer. There is one Record per year (in the same table) for which the customer is not filled. This record holds the unallocated turnover.
If I add a record to the table for a specific customer and year, the unallocated turnover should be recalculated.

Environment is Baan ERP 5.0 c on Solaris with Oracle as database.

I did the following:

In the after.save.object (persuming that the db.update for the record with the customer has taken place here), I make a select on the record (delayed lock) without customer, subtract the turnover of the record with the customer in it, and do a db.update on the record without the customer.

I get a "201 record changed after delayed lock" and I do not get it why.

The code (simplified)
after.save.object:
select *
from alcom001 for update
where alcom001._index1={"",:year}
selectdo
alcom001.tovr = tovr
db.update(talcom001,db.retry)
endselect

I put the code in a dll but (as I explected) this didn't change anything. Playing around with retry points or commits didn't bring anything.

Any ideas?

Evert-Jan Bosch
19th May 2005, 15:25
Is the update you programmed in after save object on the same table as the main table of the DAL? If so, try this string g.save.alcom001(1) based
long g.save.alcom001.dlock

function long after.save.object()
{
static long s.length

if s.length = 0 then
db.row.length(talcom001, s.length)
alloc.mem(g.save.alcom001, s.length)
endif
g.save.alcom001 = rcd.talcom001
g.save.alcom001.dlock = alcom001._dlock

select alcom001.*
from alcom001 for update
where alcom001._index1={"",:year}
selectdo
alcom001.tovr = tovr
db.update(talcom001,db.retry)
endselect

rcd.talcom001 = g.save.alcom001
alcom001._dlock = g.save.alcom001.dlock

return(0)
}

baanconsultant
19th May 2005, 17:51
Seems to work just as I need it!!

Thanks!

(en alvast gefeliciteerd ;)

baancust
10th May 2008, 14:50
Hi,

I have the similar problem but i am not updating maintable. can you help me what to do in this case??

Regards,
Baancust