simona
18th June 2008, 14:17
Hello there,
I'm using Baan IV c4.
How can I lock the table while I;m updating it. I want to avoid that another user try update it in the same time.
There is something like db.check.row.dlocked() or sometrhing else for Baan IV?
Thank you,
Simona
ulrich.fuchs
18th June 2008, 14:27
db.retry.point ()
select tiitm001.*
from tiitm001 for update | Creates a "delayed lock" on the record
where ...
order by tiitm001._index1 with retry | resume at the current item when a locking conflict occurs
selectdo
tiitm001.dsca = "foo"
db.update (ttiitm001, db.retry) | Actually locks the record
commit.transaction ()
endselect
should do
Uli
Kozure Ohashi
18th June 2008, 14:28
long db.lock.table( long table_id )
Description
This locks a specified table. Other users cannot then write to or delete the table or any parts of the table. Nor can they lock the table or any parts of the table. The lock is released by commit.transaction() or abort.transaction().
Return values
0 success
<>0 error
Regards,
Kozure
simona
18th June 2008, 15:11
Hi Kozure,
I tried with db.lock.table() but I get error 203="Action not allowed within transaction".
my script is:
db.lock.table(ttfcmg000)
select tfcmg000.*
from tfcmg000 for update
selectdo
tfcmg000.bdir = tfcmg000.bdir + 1
db.update(ttfcmg000, db.retry)
select tfcmg409.*
from tfcmg409
where tfcmg409._index1 = {:tfcmg000.bdir}
selectempty
tfcmg409.btno = tfcmg000.bdir
tfcmg409.user = user
tfcmg409.stdd = tfcmg.stdd.selected
tfcmg409.date = date.num()
db.insert(ttfcmg409, db.retry)
endselect
endselect
commit.transaction()
regards,
simona
mark_h
18th June 2008, 15:18
You don't need to use db.lock. Use db.retry.point () insteand just like Ulrich.fuchs recommended. This will lock the table while you do an update.
Kozure Ohashi
18th June 2008, 18:00
My understanding was, you want to lock the whole table while processing your statements.
Regards,
Kozure
vaishali_sftdev
17th July 2008, 12:17
Hi,
This thread is very old. But it raised question in my mind that all these are used for the same purpose? for update also locks the table as db.lock.. but db.retry.point is has some other purpose? Plz, can someone make it clear.. :confused: And when do we require db.lock if its purpose is to update the whole table? Any example.
cyprus
17th July 2008, 13:25
Hi,
This thread is very old. But it raised question in my mind that all these are used for the same purpose? for update also locks the table as db.lock.. but db.retry.point is has some other purpose? Plz, can someone make it clear.. :confused: And when do we require db.lock if its purpose is to update the whole table? Any example.
db.lock.table() locks the entire table, so that no other user can modify/delete any record from that table till this lock exists...
"for update" (delayed locking) locks the particular record selected thru the select query (not all records), so that this particular record cannot be modified/deleted by other users. Other records in table can still be modified/deleted while this lock is on.:cool:
Hope u got some clearity ...:)
vaishali_sftdev
21st July 2008, 08:57
You don't need to use db.lock. Use db.retry.point () insteand just like Ulrich.fuchs recommended. This will lock the table while you do an update.
yes, cyprus.. thank u for reply.. And as mark said that instead of using db.lock, he has suggested db.retry.point. So, what advantage it will provide over db.lock except reexecuting a transaction? Since, it is used for reexecuting a transaction.. But locking a record is done here by for update clause in the query. right? Does he mean same?
Thanks.
cyprus
21st July 2008, 09:16
Hi Vaishali,
If you are updating a record in a table, there is no point in locking the entire table using db.lock(), instead you will prefer locking the particular record which you can do by using "for update" and db.retry.point() so that others can still work on the remaining records of the table ...
Both the locking are important and have their advantages depending on their use ...