A very common mistake when working with the guy numeric(precisão, escala)
is to think that precision indicates how many digits will fit in the whole part.
In fact, precision will indicate how many digits the whole number will have, including the decimal places.
See the following example:
SELECT CAST(123456 AS NUMERIC(6, 4))
The field will burst because it will be interpreted as 123456.0000
So for the example type, the highest value that will fit in the field is 99.9999
Even 99.99999 will not be accepted, as it will eventually be rounded to 100.0000
The value 99.99994 will be accepted, as it will be rounded to 99.9999
To know the highest value accepted by a NUMERIC field do ((10 ^ precisão)/(10 ^ escala)) - (1/(10^escala))
Example using NUMERIC(3, 3)
((10 ^ 3)/(10 ^ 3)) - (1/(10 ^ 3))
(1000/1000) - (1/1000)
1 - 0.001
0.999
This is one of the situations I learned on a day-to-day basis, because not even in the manual does the formula of knowing what is the highest value of a field.
Note: It is not possible to have field with less precision than scale
They are values that come to integration. They are Nfs values, wanted something to validate these values not to burst in the bank.
– Mayron Ceccon
can you change the field type? when you say NF values is talking about right money?
– rray
I can not change the type we have many registered values and other points to register in this table. Yes money.
– Mayron Ceccon
That’ll be of some help?
<?php
define('LIMITE', 10000000000);
$valor = 90000000000;
if($valor > LIMITE ){
 echo 'vai estoura o limite';
}
– rray
It worked! Thank you so much @rray !
– Mayron Ceccon