Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Data type mismatch error when adding a new record
Message
From
13/10/2004 10:06:17
 
 
To
13/10/2004 09:33:35
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00950955
Message ID:
00951053
Views:
19
>Hi Fabio,
>
>Apparently I didn't make my point clear enough (which I thought I had with the repro code):
>
>1. We have an existing VFP8 application working on a bunch of tables, each has a candidate index (on field c1 in my example, with no filter), also an autoinc field (c2 in my example)
>
>2. To prevent the documented (thus expected) "Field C1 is read only" error (VFP error 2088) when issuing any GATHER MEMVAR statement, we already have the AUTOINCERROR set to OFF in our application
>
>3. Everything worked fine up to this point, until I decided to introduce an index filter "FOR !DELETED()" to the candidate index (on field C1 as in my example), then I started to get this "Data type mismatch" error (VFP error 9, not on field C1, but on filed C2). This is beyond my expectation because I can't find an explanation for this behaviour, why a seemingly small change to one field triggers an error on another (to me it's a totally irrelevant error).
>
>Obviously your explanation to the issue ("C2 is a read only field") does not apply here, because I don't get that error (error 2088) in the first place. If the catch-all "SET AUTOINCERROR OFF" could do without the need of something like the "EXCEPT C2" part in every single GATHER statement, I'd pretty much appreciate it.
>
>So the point is, if a TABLE change requires CODE change in a resonalbe way I can live with it, but in this case it does not appear to.


Simple, this is a VFP8 bug. It is fixed on VFP9.
* repro code, Visual FoxPro error 9 - what's wrong here?
CLOSE DATABASES ALL
CLOSE TABLES ALL
SET AUTOINCERROR OFF
SET MULTILOCKS ON

* create a temporary table, with only 2 fields (one of them is autoinc!)

CREATE TABLE ADDBS(SYS(2023))+SYS(2015) FREE (c2 i autoinc)

* any index with a FOR clause fire the bug
INDEX ON .T. TAG c1 FOR .T.

USE DBF() SHARED && must be "shared" to see the error
CURSORSETPROP('buffering', 5) && optimistic table buffering

* you can add values
INSERT INTO (ALIAS()) (c2) VALUES (1)

TRY
        && you cannot update the autoincr
	REPLACE c2 WITH 3

	MESSAGEBOX('It worked', 0, 'Cool', 2000)
CATCH TO loEx
	MESSAGEBOX('SORRY, a error occurs', 48, loEx.message)
FINALLY
	DROP TABLE (DBF())
ENDTRY
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform