using locktable

db
Member Posts: 82
That for needed locktable, if this func don't locks table ???
I need to lock some tables, some recs of tables are modified only at the end of code execution.
For undersanding locktable I write following code:
IF CONFIRM('Lock?') THEN
BEGIN
w.OPEN('#1#######');
t17.LOCKTABLE();
i:=10;
REPEAT
SLEEP(1000);
i:=i-1;
w.UPDATE(1,i);
UNTIL i=0;
END;
w.CLOSE;
Running this code on two machines NO ANY STOP ON LOCKTABLE !!!
I use NF 1.30
I need to lock some tables, some recs of tables are modified only at the end of code execution.
For undersanding locktable I write following code:
IF CONFIRM('Lock?') THEN
BEGIN
w.OPEN('#1#######');
t17.LOCKTABLE();
i:=10;
REPEAT
SLEEP(1000);
i:=i-1;
w.UPDATE(1,i);
UNTIL i=0;
END;
w.CLOSE;
Running this code on two machines NO ANY STOP ON LOCKTABLE !!!
I use NF 1.30
0
Comments
-
LOCKTABLE is activated when you perform the first database modification on a table - quite clever actually. Try this instead:
IF CONFIRM('Lock?') THEN
BEGIN
w.OPEN('#1#######');
t17.LOCKTABLE();
t17.MODIFY;
i:=10;
REPEAT
SLEEP(1000);
i:=i-1;
w.UPDATE(1,i);
UNTIL i=0;
END;
w.CLOSE;0 -
I was under the impression (from the documentation) that the write (MODIFY) performs an implicit lock all by itself. And that LOCKTABLE all by itself performs an explicit lock. So, in the second example, the t17.LOCKTABLE() is unnecessary becuase the next statement (t17.MODIFY() <img border="0" title="" alt="" src="images/smiles/icon_wink.gif" /> will lock the table.
-jp-jp0 -
Hello Dalius,
The table actually is locked after you first read from it.
Modify your code as following and check it up:
<BLOCKQUOTE><font size="1" face="Verdana, Arial">code:</font><HR><pre>
IF CONFIRM('Lock?') THEN
BEGIN
w.OPEN('#1#######');
t17.LOCKTABLE();
t17.FIND('-'); // Insert this line
i:=10;
REPEAT
SLEEP(1000);
i:=i-1;
w.UPDATE(1,i);
UNTIL i=0;
w.CLOSE;
END;
</pre><HR></BLOCKQUOTE>
Best regards,
Otto Dreyer
NRG Ltd.
[This message has been edited by Otto Dreyer (edited 23-03-2000).]0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions