Record Variable Using Cached Values??

headley27
Member Posts: 188
Here's the Scenario:
Custom Report #1
The problem that I have is that the 'current' value isn't always pulled from this table as though it is being 'cached' somehow.
This is an extreme example (I only need to run Report #2 once) but it will explain what I am facing:
Querying the database using Rec.GET does not always pull the current value from the SQL database.
There is no rhyme or reason as to which value it decides to use. Sometimes it's the current value, sometimes it's the cached value.
I have tried Rec.RESET as well as SELECTLATESTVERSION without success. ](*,)
Has anyone experienced this issue?
Thank you very much for your assistance.
Custom Report #1
-
Used by Purchasing Staff
Modifies a Custom Table to update it's state: 'Active' (On PreReport) or 'Inactive' (OnPostReport)
-
Used by Warehouse Staff
Shouldn't be run when Report #1 is running
Reads the Custom Table to determine if Report #1 is running
The problem that I have is that the 'current' value isn't always pulled from this table as though it is being 'cached' somehow.
This is an extreme example (I only need to run Report #2 once) but it will explain what I am facing:
-
Step 1: I start Report #2 . 'Inactive' state is correctly returned for Report #1 (Report #2 runs for 1 minute).
Step 2: I start Report #1 after Report #2 has finished running (Report #1 runs for 10 minutes).
Step 3: I start Report #2 while Report #1 is running. 'Inactive' state is incorrectly returned (runs for 1 minute).
Step 4: I start Report #2 again while Report #1 is running. 'Inactive' state is still incorrectly returned (runs for 1 minute).
Step 5: I start Report #2 a third time while Report #1 is running. 'Active' state is now correctly returned (runs for 1 minute).
Step 6: Report #1 finishes running.
Step 7: I start Report #2. 'Active' state is incorrectly returned (runs for 1 minute).
Step 8: I start Report #2 again. 'Inactive' state is correctly returned (runs for 1 minute).
Querying the database using Rec.GET does not always pull the current value from the SQL database.
There is no rhyme or reason as to which value it decides to use. Sometimes it's the current value, sometimes it's the cached value.
I have tried Rec.RESET as well as SELECTLATESTVERSION without success. ](*,)
Has anyone experienced this issue?
Thank you very much for your assistance.
0
Comments
-
I will try to give you some tips.
1) Make sure when you set your state (active/inactive) that you put a COMMIT (use wisely), so that the state is commited to the database. Do this OnPreReport as well as OnPostReport.
2) With CLEAR(recVar) you get a fresh copy of your data to your variable.
3) You might want to forget about all this, and play arround with LOCKTABLE and such ... :-k
I know that on SQL Server, NAV reads uncommitted data (READUNCOMMITTED). This might be the reason that it's behaving this way. Off course, only when you didn't put a COMMIT after the change of state...0 -
Thanks Waldo.
I had been commiting the state to the database. I can see the change happen using SQL Enterprise Manager / Query Analyzer.
I tried the Clear() function without success.
What do you mean by 'play around with LOCKTABLE and such ...'
Thanks again.0 -
Maybe even locktable on report one and if not modify on report 2?0
-
Thanks for the explanations Waldo & Mbad.
I can't lock the table in question but I do have more to add.
Again, my example was a bit extreme.
It was provided to present what I seemed to be experiencing.
I have confirmed however that the steps should have read:-
Step 1: I start Report #2 . 'Inactive' state is correctly returned for Report #1 (Report #2 runs for 1 minute).
Step 2: I start Report #1 after Report #2 has finished running (Report #1 runs for 10 minutes).
Step 3: I start Report #2 while Report #1 is running. 'Inactive' state is incorrectly returned (runs for 1 minute).
Step 5: Ignore
Step 6: Report #1 finishes running.
Step 7: I start Report #2. 'Active' state is incorrectly returned (runs for 1 minute).
Step 8: I start Report #2 again. 'Inactive' state is correctly returned (runs for 1 minute).A minor difference, but I just wanted to note that the issue wouldn't persist beyond 1 full pass of Report #2 while Report #1 was running.
The issue would correct itself in less than 1 minute, never more.
I ran some tests where I would start Report #1 and then run Report #2 immediately following.
If I didn't get the expected warning message, I would cancel Report #2 and quickly re-open it.
I would continue to do so until Navision displayed the proper warning message.
The average time that Navision would take to grab the value that I was expecting seemed to be between 15 and 20 seconds.
I am a little confused considering the correct values were returned instantly by SQL Query Analyzer, SQL Enterprise Manager and (if I recall correctly) even the Navision Debugger but not the Navision Client.
Anyways, to make a long story short, I figured that I could live with a 15 to 20 second delay as it was better than doing nothing.
I saved the changes to the database (I was previously running Report #2 using Tools > Designer > File > Run as I was testing my changes before saving them).
As strange as it may sound everything now works fine. Since recompiling the object (Report #2), this issue does not seem to be occuring.+ :shock: + :-k
I don't really understand what has happened here but perhaps someone could shed some light.
Thanks again for your assistance.0 -
No, I hadn't.
Everything seems to be working as it should, but I will keep this in mind should further modifications be required.
Thanks again.0 -
headley27 wrote:No, I hadn't.
Everything seems to be working as it should, but I will keep this in mind should further modifications be required.
Thanks again.
When I think of it ... a single instance codeunit won't work with your problem ... it only works when using one client, and I suppose you're using more than one :oops:0 -
headley27 wrote:...
I saved the changes to the database (I was previously running Report #2 using Tools > Designer > File > Run as I was testing my changes before saving them).
As strange as it may sound everything now works fine. Since recompiling the object (Report #2), this issue does not seem to be occuring.+ :shock: + :-k
I don't really understand what has happened here but perhaps someone could shed some light.
Thanks again for your assistance.
This is weird. This was a known bug in version 2.50, and I think it was in at least one service pack in 2.60, but I have not seen it in any of the new versions.
Which version of finsql are you running.David Singleton0 -
I am using 3.70A.
Perhaps I am not losing my mind afterall.
Strange...isn't it.0 -
Waldo wrote:May be you can do a runtime upgrade to the latest version (4.0SP3 or may be even 5.0)? I think you got a pretty good reason to do this
Where is the best place to start researching this?
I would assume that I would need help from a consultant to implement such a change but would like to do some of my own legwork first so that I understand at least some of what is involved.
For example, my system is heavily customized in key sections (a custom pricing engine, reservation modifications, etc.) ....
.... Can I even upgrade or is Navision built to handle upgrades with heavy customization?
Thanks for your help.0 -
Just upgrading the executables means uninstall all the clients, then install the new version. You then just connect to the existing server.
But yes you should do it with your consultant for the first time, at least them there as a backup if something goes wrong.David Singleton0 -
David Singleton wrote:Just upgrading the executables means uninstall all the clients, then install the new version. You then just connect to the existing server.
Wow. That's great to know.
I thought you had to upgrade the server at the same time.
I have a current support contract with Microsoft so I am pretty sure the upgrade will be covered.
You learn something everyday. Thanks so much.
Kudos to Waldo and David Singleton.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