When Do I Need To Use LockTable?

ayashi
Member Posts: 78
Hi guys,
If I create a form, with a button, which when this button pushed, it will explode several record into a custom table (inserting).
If I do this in multi-user environment, do I need to lock the custom table ? so that other users won't interfere in the middle of inserting the records ?
Thanks
If I create a form, with a button, which when this button pushed, it will explode several record into a custom table (inserting).
If I do this in multi-user environment, do I need to lock the custom table ? so that other users won't interfere in the middle of inserting the records ?
Thanks
0
Comments
-
If run in a c/side environment Navision will lock the table after the first change to the table and keep the lock active until the transaction is completed.0
-
You need to use tablelock when:
1) You need to keep correct locking order, but you are accessing the tables in another order...
2) You need to prevent other users to change or access same record you just read (for example, you read last entry no. and you want to insert some new record later in the process, this will prevent other users to read the last record to do same thing, it will be serialized...)
3) You want to be sure that you are reading commited data.0 -
talk about commited data .. perhaps my next question a little bit out of topic. If I have this code :
x := 1
Repeat
If x = 5 Then
Error(Text001)
Else Begin
Table.INIT;
Table."No." := x;
Table.INSERT;
End;
x := x + 1;
Until x = 10;
Does this mean when the program raise error message (x=5) and the application stop, the record for x = 1..4 already inserted into the table ?
or Navision automatically rollback, so that when I open the Table, there won't be any record ?
Thank Guys0 -
Of course, whole transaction is rolled back. The database will be in same state like after last commit or before you started the process (by pressing button, entering value into field etc.)0
-
thx a lot kine for answering,
then when do we use commit command ? cause in several navision code, I see some module using 'commit' command0 -
Normally in your code you should not use commit.
Places where commit make sense is if you
write your own posting routine.
write integrations with third party system.
batch processing orders.
catching errors in "if CU.run"
openning a form at the end of transaction.
dataports sometimes do not commit, and you have to write on postdataport COMMIT0 -
Ok thanks a lot you all for explaining it to me in simple language so that I could understand it0
-
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