SQL Locking

DeputyDogh
Member Posts: 7
Navision Version 4.0 SP3
I've a question about the locking in NAV 403 on a SQL2005 database
Always rowlock = Yes
If we look at the following code, we see that we want to change the record recWhseJnlLine. That's why we've used the findset(true,false)
The result is a locking of 9 records. There are 9 records which comply to the filters set in the CAL code.
recWhseJnlLine.RESET;
recWhseJnlLine.SETCURRENTKEY("Location Code","Item No.","To Zone Code");
recWhseJnlLine.SETRANGE("Location Code",'WHSE');
recWhseJnlLine.SETRANGE("To Zone Code",'STOCK6');
recWhseJnlLine.SETRANGE("Item No.",'CAD25B');
IF recWhseJnlLine.FINDSET(TRUE,FALSE) THEN BEGIN
dQtyOnWhseJnlLine := 0;
REPEAT
recZone.GET(recWhseJnlLine."Location Code",recWhseJnlLine."To Zone Code");
dQtyOnWhseJnlLine+=recWhseJnlLine."Qty. (Base)";
recWhseJnlLine.description := 'NEW';
recWhseJnlLine.modify;
UNTIL recWhseJnlLine.NEXT = 0;
END;
When we look at the following code we want tot do some reading in the same table. We even use another variable of the same table but Navision sends alway a ROWLOCK and an UPDLOCK to the SQL once there has previously been a locking on the same table.
WHen i check : I can see that after these lines of code, 512 records are locked. The ones in the previous CAL code and the ones which have been read in the CAL code beneath.
Is this a normal behaviour or is this a bug ?
recWhseJnlLine.RESET;
recWhseJnlLine.SETCURRENTKEY("Location Code","Item No.","To Zone Code");
recWhseJnlLine.SETRANGE("Location Code",'WHSE');
recWhseJnlLine.SETRANGE("To Zone Code",'STOCK6');
recWhseJnlLine.SETFILTER("Item No.",'C*');
IF recWhseJnlLine.FINDSET(FALSE,FALSE) THEN BEGIN
dQtyOnWhseJnlLine := 0;
REPEAT
recZone.GET(recWhseJnlLine."Location Code",recWhseJnlLine."To Zone Code");
dQtyOnWhseJnlLine+=recWhseJnlLine."Qty. (Base)";
UNTIL recWhseJnlLine.NEXT = 0;
END;
It is not always common to put in commit's just to avoid this.
Can Someone help please
Thanks
DD
I've a question about the locking in NAV 403 on a SQL2005 database
Always rowlock = Yes
If we look at the following code, we see that we want to change the record recWhseJnlLine. That's why we've used the findset(true,false)
The result is a locking of 9 records. There are 9 records which comply to the filters set in the CAL code.
recWhseJnlLine.RESET;
recWhseJnlLine.SETCURRENTKEY("Location Code","Item No.","To Zone Code");
recWhseJnlLine.SETRANGE("Location Code",'WHSE');
recWhseJnlLine.SETRANGE("To Zone Code",'STOCK6');
recWhseJnlLine.SETRANGE("Item No.",'CAD25B');
IF recWhseJnlLine.FINDSET(TRUE,FALSE) THEN BEGIN
dQtyOnWhseJnlLine := 0;
REPEAT
recZone.GET(recWhseJnlLine."Location Code",recWhseJnlLine."To Zone Code");
dQtyOnWhseJnlLine+=recWhseJnlLine."Qty. (Base)";
recWhseJnlLine.description := 'NEW';
recWhseJnlLine.modify;
UNTIL recWhseJnlLine.NEXT = 0;
END;
When we look at the following code we want tot do some reading in the same table. We even use another variable of the same table but Navision sends alway a ROWLOCK and an UPDLOCK to the SQL once there has previously been a locking on the same table.
WHen i check : I can see that after these lines of code, 512 records are locked. The ones in the previous CAL code and the ones which have been read in the CAL code beneath.
Is this a normal behaviour or is this a bug ?
recWhseJnlLine.RESET;
recWhseJnlLine.SETCURRENTKEY("Location Code","Item No.","To Zone Code");
recWhseJnlLine.SETRANGE("Location Code",'WHSE');
recWhseJnlLine.SETRANGE("To Zone Code",'STOCK6');
recWhseJnlLine.SETFILTER("Item No.",'C*');
IF recWhseJnlLine.FINDSET(FALSE,FALSE) THEN BEGIN
dQtyOnWhseJnlLine := 0;
REPEAT
recZone.GET(recWhseJnlLine."Location Code",recWhseJnlLine."To Zone Code");
dQtyOnWhseJnlLine+=recWhseJnlLine."Qty. (Base)";
UNTIL recWhseJnlLine.NEXT = 0;
END;
It is not always common to put in commit's just to avoid this.
Can Someone help please
Thanks
DD
0
Comments
-
If you call locking on the table from one variable, it will lock from other variables too... it is normal behavior...0
-
Does this mean that when i lock 1 record to update it, and afterwards i only want to read 10.000 other records in the same table that i have to use a commit to end the transaction and then do the reading ?
I can't imagine that this was meant to be like this.
In my example first the 1 record is locked for the update. This seams ok. But the other 10.000 are also locked and this is causing a lot of problems.
How can this be solved ?0 -
DeputyDogh wrote:I can't imagine that this was meant to be like this.DeputyDogh wrote:How can this be solved ?Regards
Peter0 -
Hi Bart,
I hope the phonecall we had cleared the issue.
Yes, the 'lock level' is at transaction level and can not be reversed.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