eric.dizon
9th January 2014, 20:04
I added this function in my cxmkt010 table DAL. I am trying to undo some stats and field values that were generated from adding new records on the same DAL. But when I execute this command I get Error 206 Record not locked for cxmkt010. Can you please help what I can do about it?


function extern long before.destroy.object()
{
ret = undo_optedout(cxmkt010.emno)
return(0)
}


function long undo_optedout(domain tcorno l.emno)
{
db.retry.point()
select * from
tccom600
where tccom600.emno = {:l.emno} and (tccom600.resp = 40 or tccom600.resp = 30)
selectdo
select tccom140.*
from tccom140 for update
where tccom140._index1 = {:tccom600.ccnt}
selectdo
if etol(tccom600.resp) = 40 then
tccom140.opou = ltoe(2)
else
if etol(tccom600.resp) = 30 then |bounce
tccom140.boun = tccom140.boun - 1
endif
endif
db.update(ttccom140,db.retry)
commit.transaction()
endselect
endselect
return(0)
}

bhushanchanda
9th January 2014, 21:07
Hi,

Not using DAL? Anyway, try this:-

extern domain tcpono flag
function long undo_optedout(domain tcorno l.emno)
{

flag = 0
select tccom600.* from
tccom600
where tccom600.emno = {:l.emno} and (tccom600.resp = 40 or tccom600.resp = 30)
selectdo
db.set.to.default(ttccom140)
select tccom140.*
from tccom140 for update
where tccom140._index1 = {:tccom600.ccnt}
selectdo
if etol(tccom600.resp) = 40 then
tccom140.opou = ltoe(2)
else
if etol(tccom600.resp) = 30 then |bounce
tccom140.boun = tccom140.boun - 1
endif
endif
db.update(ttccom140,db.retry,elocked)
flag = 1
endselect
endselect

if flag = 1 then
commit.transaction()
endif
return(0)
}

Also check the board for similar threads. There are many.

eric.dizon
9th January 2014, 21:31
Thanks for your reply.
Hi this code is actually inside my cxmkt010 DAL and I tried the code you've illustrated I am still getting same error

Fatal error : Error 206 (Record is not locked) on cxmkt010600 in db_delete(51)
Cannot continue in cxmkt0010m00 in DLL : ottspstandard (rcdset.delete) [db.delete]


function long undo_optedout(domain tcorno l.emno)
{
flag = 0
db.retry.point()
select * from
tccom600
where tccom600.emno = {:l.emno} and (tccom600.resp = 40 or tccom600.resp = 30)
selectdo
db.set.to.default(ttccom140)
select tccom140.*
from tccom140 for update
where tccom140._index1 = {:tccom600.ccnt}
selectdo
if etol(tccom600.resp) = 40 then
tccom140.opou = ltoe(2)
else
if etol(tccom600.resp) = 30 then |bounce
tccom140.boun = tccom140.boun - 1
endif
endif
db.update(ttccom140,db.retry,elocked)
flag = 1
endselect
endselect

if flag=1 then
commit.transaction()
endif
return(0)
}

bhushanchanda
9th January 2014, 21:41
Hi,

Try removing the commit.transaction().

Also, try something like this:-

Thread! (http://www.baanboard.com/baanboard/showthread.php?t=6236)

eric.dizon
9th January 2014, 21:46
That worked by the way. Thanks a lot. Can you please enlighten me why I didn't need the commit.transaction for this instance?

bhushanchanda
9th January 2014, 21:54
Hi,

May be because there involves commit's in the DLL which also commits the table which you are trying to update. So, it locks the table for any further commits. Hence causing the error.

Initially I thought, its a standalone DAL for a session. But, as the error shows, something else was involved too.

Anyway, glad it worked for you!