using locktable

dbdb Member Posts: 82
edited 2000-03-23 in Navision Financials
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

Comments

  • JBLJBL Member Posts: 1
    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;
  • jpjp Member Posts: 47
    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
    -jp
  • Otto_DreyerOtto_Dreyer Member Posts: 16
    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).]
Sign In or Register to comment.