Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric Field precision / digits oddity???
Message
From
19/11/2012 14:16:57
 
 
To
19/11/2012 11:44:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01557585
Message ID:
01557596
Views:
49
>I have a field in a table that is defined as N(5,1), which would normally allow values like 100.0, with a maximum value of 999.9
>
>However, I have discovered some rows in my table where the values are these values: 1000, 1500, and even 5000 (notice how all 4 digits are used before the decimal.)
>
>I was a surprised to see values this high in a few fields, as I thought VFP would not even accept these values, as they are not in compliance with the field definition, although I can understand that with some liberal use of the field size, there is enough room to store these larger values. However, it seems kind of sloppy for VFP to allow this.
>
>BTW - in a Browse window I cannot enter such a large value in that field, yet from the Command window, I can say
>
>
>REPLACE <field> WITH 1000
>
>
>and it will accept the larger value.
>
>I know that in my code this field value is set by a REPLACE command in my processing logic, so I can easily understand how/why I have some values this large in my table.
>
>Either way, I'm still surprised that VFP will accept the value.

VFP's N(x,y) is not a numeric data, but a char.

VFP store the STR(aa,x,y) into the table not the aa numeric value.
CLEAR
CREATE CURSOR aa (bb N(5,1))
APPEND BLANK
REPLACE BB WITH 1.1
? BB,STR(1.1,5,1)
REPLACE BB WITH -99.9
? BB,STR(-99.9,5,1)
REPLACE BB WITH -999.9
? BB,STR(-999.9,5,1)
REPLACE BB WITH 9999.5
? BB,STR(9999.5,5,1)
REPLACE BB WITH 9999.1
? BB,STR(9999.1,5,1)
try
REPLACE BB WITH 999999
catch
endtry
? BB,STR(999999,5,1)
Previous
Reply
Map
View

Click here to load this message in the networking platform