smusba
1st December 2010, 08:18
Dear Gurus,

I get the following error while updating the tiitm001.ltcp and ticpr300.indt field by inputting the date manually in the session.

Error 206 (Record is not locked) on ticpr300786 in db_update(51)
Cannot continue in tiitm1201m611(<7>).

My script is

functions:


function read.main.table1()
{

item = ""
itemc = ""
db.retry.point()
select ticpr300.*
from ticpr300 for update
where ticpr300.item = :item.f
order by ticpr300.item, ticpr300.indt desc
as set with 1 rows
selectdo


if ticpr300.indt = date.num() then
itemf = ticpr300.item
db.retry.point()
select tiitm001.*
from tiitm001 for update
where tiitm001.item = :item.f

selectdo
|display("tiitm001.dsca")
tiitm001.kitm =tckitm.purchase
|tiitm001.copr = copr.f
|tiitm001.matc = copr.f
tiitm001.ltcp = date.f
db.update(ttiitm001,db.retry)

ticpr300.item = item.f
ticpr300.cntr = tiitm001.cntr
ticpr300.indt = tiitm001.ltcp
ticpr300.cpcp = "001"
ticpr300.nuni = 1.00
ticpr300.actf = 1.00
ticpr300.amnt = tiitm001.copr
db.update(tticpr300,db.retry)
commit.transaction()
message("THE ITEM %s IS UPDATED NOW",tiitm001.item)
endselect

endif

if ticpr300.indt <> date.num() then
itemnf = ticpr300.item
db.retry.point()
select tiitm001.*
from tiitm001 for update
where tiitm001.item = :item.f

selectdo
|display("tiitm001.dsca")
tiitm001.kitm =tckitm.purchase
|tiitm001.copr = copr.f
|tiitm001.matc = copr.f
tiitm001.ltcp = date.f
db.update(ttiitm001,db.retry)
commit.transaction()
ticpr300.item = item.f
ticpr300.cntr = tiitm001.cntr
ticpr300.indt = tiitm001.ltcp
ticpr300.cpcp = "001"
ticpr300.nuni = 1.00
ticpr300.actf = 1.00
ticpr300.amnt = tiitm001.copr
db.update(tticpr300,db.retry)
commit.transaction()
message("THE ITEM %s IS UPDATED NOW",tiitm001.item)
endselect

endif

item = ticpr300.item

endselect

}

amitmmokashi
1st December 2010, 14:20
Hi,

In the condition "if ticpr300.indt <> date.num()", there is an additional commit.transaction() for table tiitm001. Use commit.transaction() only for table ticpr300.

Regards,
Amit Mokashi

BaanInOhio
1st December 2010, 18:01
Too many 'db.retry.point()' calls. It should only be used before the first select statement (as you have set). The locations for the 'commit.transaction()' calls seem to be fine for what you are doing. The calls to 'db.retry.point()' before the tiitm001 selects will stop the transaction for ticpr300, which is expected to be active for the 'db.update' calls.

toolsjb
6th December 2010, 05:42
Hello.
I'd remove all commit.transaction() and all db.retry.point() but first
and put commit.transaction() in the end - after endselect.
It seams transaction is not big, so it's not necessary to run commit.transaction() more then once.