This occurs in the following line (in some customized code, not standard Nav):The Following ODBC error occurred
Error: [Microsoft] [ODBC SQL server driver] Numeric value out of range
State ID: 22003
PVJobCalculationUnit."Quote price" := PVJobCalculationUnit."Price calculated"/SumOfOfferedPrice * BasePrice;It only comes up while processing one or two documents, in most cases the code is executed without problem.
ldec_interim := PVJobCalculationUnit."Price calculated" / SumOfOfferedPrice; PVJobCalculationUnit."Quote price" := ldec_interim * BasePrice;A colleague suggested that the error might be caused by having too many numbers AFTER (rather than before) the decimal point, but the problem still occurred when I used the ROUND function. (Besides, setting PVJobCalculationUnit."Quote price" to 1/3, i.e. 0.33333333…. did not cause any problems.)
Answers
They already have the latest SQL updates (Windows Update only shows some optional updates, none of which are for SQL; and no high-priority updates).
I wonder if it goes out of range when it calculates
PVJobCalculationUnit."Price calculated"/SumOfOfferedPrice
I would try changing the calculation to
PVJobCalculationUnit."Quote price" := ( BasePrice * PVJobCalculationUnit."Price calculated" ) / SumOfOfferedPrice
I doubt that windows update is enough to be sure the latest version of SQL server is installed. Rather use this link: http://support.microsoft.com/kb/321185/en-us
Help - About in SQL SMS shows that they are on build 4035, which is the base version of SQL 2005 SP 3.
According to http://support.microsoft.com/kb/960598 the latest build is 4309, which is Cumulative Update 11 for SP3.
However, these fixes are only available on request, with a disclaimer that: The specific error mentioned here was not reported or fixed for SQL 2005, and I'm not going to suggest that our client install fixes for several unrelated issues, against the explicit recommendation of MS, even more so when the issue we're trying to fix is very minor.
You are right about that...
The quantities are:
"Price calculated" 89.2
BasePrice 2,640.75875
SumOfOfferedPrice 3,018.01
I imagine that it would go out of range when multiplying numbers, not when dividing (unless it divides by a quantity less than 1, which is not the case here).
But as you can see, the numbers (even when multiplied) are well below the maximum allowed for decimal fields or variables.
Anyway, I tried your suggestion, and unfortunately it didn't resolve the problem.
I also tried splitting the calculation into two, i.e. This also did not solve the problem.
If you use Management Studio and open the database, tables, find the table name and expand the columns.
The column type should show Decimal(38,20).
This posting is provided "AS IS" with no warranties, and confers no rights.
The value of "Price Calculated" does not change in this calculation, but for what it's worth, it's a FlowField that sums up the Sales Amount field in PV Job Calculation Detail, which is also decimal(38,20).
ldec_interim is a decimal variable in C/SIDE.
I commented out the line of code mentioned in my first post, and the error still came up. The Nav debugger was misleading - the error was actually occurring on a different line, namely I should have guessed that an SQL error would come up not when we change the value of some field in Navision, but when we try to write that value to the table.
I found that one of the decimal fields had value 4,477,000,000,000,000,100 which is definitely out of range.
I can now continue debugging as usual. The main lesson to remember (especially if some lines are commented out) is that:
the line indicated by the Nav debugger need not be the exact line being executed .