chjagge
13th August 2004, 22:03
I have a maintain session with the primary table tdsls997. After updating a field in this session I want to update another table tdsls998. I've been getting either "Transaction is on;" or Error 206 Record is not locked. Any ideas on how I can do this?

I tried -
field.tdsls997.status:
when.field.changes:
db.retry.point()
select tdsls998.*
from tdsls998 for update
where tdsls998._index1 = {:tdsls997.orno, :tdsls997.pono}
order by tdsls998._index1
selectdo
tdsls998.lockcd = tdsls997.lockcd
db.update(ttdsls998, db.retry)
commit.transaction()
endselect

SriksAdi
14th August 2004, 08:57
Hi,
It not advisible in writing the script for update in the when.field.changes.
Make use of main.table.io section.

main.table.io:
before.rewrite:

select tdsls998.*
from tdsls998 for update
where tdsls998._index1 = {:tdsls997.orno, :tdsls997.pono}
order by tdsls998._index1
selectdo
tdsls998.lockcd = tdsls997.lockcd
db.update(ttdsls998, db.retry)
endselect

Note:
There is no need to write db.retry and commit.transaction()


regards
Sriks

lauras
17th September 2004, 18:03
What if you have marked records and you need to update the other table for each marked record in addition to the main table? Just putting in the main.io would only do the last record. We can't put the logic in the choice.mark.occur, because that doesn't allow the user any time to change his mind.

Any help would be greatly appreciated.

SriksAdi
20th September 2004, 08:31
Hi,
Sections, under main.table.io are executed for each record updated, inserted, deleted.

regards
Sriks

learner
20th September 2004, 12:29
Hi,

just a thought , i too have encountered the same problem like "Transaction is ON" and wrote the code in


after.update.db.commit:


and that solved my purpose, but seing your post as u suggested we should not use db.retry and commit.transaction in before.rewrite sub-section..... do u mean to say that could have been the reason for the the message "Transaction is ON" ???

Right now I am not on BaaN System, as soon as I get one , i will try this out.


Waiting for your reply.

Regards

Learner

SriksAdi
20th September 2004, 13:24
Hi,
As per Baan Help, The actions in this subsection are executed just after a commit.transaction(), if the database is updated.

Even if multiple records are updated in a session, the script under this section is executed only once.

As per the error Transaction is On is considered, yes, I believe that's the reason. Baan standard program (ttstp) generates db.retry() in the before.write / before.rewrite / before.delete and commit.transaction() is generated in after.write / after.rewrite / after.delete.

Using db.retry() in before.write, would try to start a new database transaction, which is not supported in Baan. Hence the error "Transaction is On"


regards
Sriks

chjagge
20th September 2004, 15:59
Thanks to all who replied. I tried Sri's solution and it worked. This is what I did.

declaration:
table ttdsls041 | Sales Order Lines
table ttdsls997 | Sales Order Line Function Server Table
table ttctkn833 | Log Table



|****************************** main table section ****************************
main.table.io:
before.rewrite:

select tdsls041.*
from tdsls041 for update
where tdsls041._index1 = {:tdsls997.orno, :tdsls997.pono}
order by tdsls041._index1
selectdo
tdsls041.lockcd = tdsls997.lockcd
db.update(ttdsls041, db.retry)
update.lines()
endselect


|***************************** function section ******************************
functions:
function update.lines()
{
domain tcmcs.str12 dte.str
dte.str = dte$()
select tctkn833.*
from tctkn833 for update
where tctkn833._index1 = {:tdsls997.orno, :tdsls997.pono, :dte.str}
selectempty
tctkn833.orno = tdsls997.orno
tctkn833.pono = tdsls997.pono
tctkn833.dtme = dte.str
tctkn833.user = logname$
tctkn833.status = tdsls997.status
tctkn833.ttyp = ttyname$()
tctkn833.trid = tdsls997.trid
tctkn833.dumm = ""
db.insert(ttctkn833, db.retry)
endselect
}