How can FINDSET fail after NOT ISEMPTY

ChaosD
Member Posts: 4
I've been seeing a very weird issue in our BC14 CU19 code where the following fails:
ItemAnalysisView2.FINDSET(TRUE, TRUE); fails with the error that no record has been found within the filter.
How is this possible immediately after ISEMPTY returned FALSE, which means there should be a record in the table? The filter doesn't change between both lines.
Could it have something to do with the .LOCKTABLE line when FINDSET(TRUE) is also implicitly calling LOCKTABLE on that record?
The full code is a modified version of the UpdateAll() function in Codeunit 7150:
[...] IF NOT ItemAnalysisView2.ISEMPTY THEN BEGIN ItemAnalysisView2.LOCKTABLE; ItemAnalysisView2.FINDSET(TRUE, TRUE); [...] END;
ItemAnalysisView2.FINDSET(TRUE, TRUE); fails with the error that no record has been found within the filter.
How is this possible immediately after ISEMPTY returned FALSE, which means there should be a record in the table? The filter doesn't change between both lines.
Could it have something to do with the .LOCKTABLE line when FINDSET(TRUE) is also implicitly calling LOCKTABLE on that record?
The full code is a modified version of the UpdateAll() function in Codeunit 7150:
ItemAnalysisView2.SETRANGE(Blocked, FALSE); IF DirectlyFromPosting THEN ItemAnalysisView2.SETRANGE("Update on Posting", TRUE); IF ItemAnalysisView2.ISEMPTY THEN EXIT; InitLastEntryNo; IF DirectlyFromPosting THEN BEGIN ItemAnalysisView2.SETFILTER("Last Entry No.", '<%1', LastValueEntryNo); IF ItemAnalysisView2.ISEMPTY THEN BEGIN ItemAnalysisView2.SETRANGE("Last Entry No."); ItemAnalysisView2.SETFILTER("Last Service Entry No.", '<%1', LastServLedgEntryNoG); END; END; IF NOT ItemAnalysisView2.ISEMPTY THEN BEGIN ItemAnalysisView2.LOCKTABLE; ItemAnalysisView2.FINDSET(TRUE, TRUE); REPEAT UpdateOne(ItemAnalysisView2, Which, ItemAnalysisView2."Last Entry No." < LastValueEntryNo - 1000); UNTIL ItemAnalysisView2.NEXT = 0; END;
0
Answers
-
Why do you call UpdateKey parameter in FINDSET? This option parameter will be removed in future releases in Business Central. Try with:
ItemAnalysysView2.FINDSET(TRUE)
I'm not sure that this is the problem, but for now I have just that idea... let's try0 -
Please make sure your SQL database checks Ok.
If it does, and the issue is repeatable, this is a case for Microsoft support.
If the issue is not repeatable, then most likely you have a race condition:You: ISEMPTY He: DELETE You: FINDSET
As a workaround just delete theIF NOT ItemAnalysisView2.ISEMPTY
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