Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seeking a string in a numeric field is OK?
Message
De
18/10/2009 05:09:26
 
 
À
15/10/2009 10:05:50
Mike Sue-Ping
Cambridge, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01429483
Message ID:
01429767
Vues:
50
>Today I discovered that VFP does not care if you try to seek a string in a numeric field.
>
>Has this always been the case? Try this code:
>
>
>CREATE CURSOR csrJunk (f1 I, f2 B, f3 N(5,2))
>
>INSERT INTO csrJunk VALUES (1, 1111.1111, 1.11)
>INSERT INTO csrJunk VALUES (2, 2222.2222, 2.22)
>INSERT INTO csrJunk VALUES (3, 3333.3333, 3.33)
>INSERT INTO csrJunk VALUES (4, 4444.4444, 4.44)
>
>INDEX on f1 TAG f1
>INDEX on f2 TAG f2 ADDITIVE 
>INDEX on f3 TAG f3 ADDITIVE  
>
>WAIT WINDOW SEEK(3, "csrJunk", 1)		&& Returns .T.
>WAIT WINDOW SEEK(3333.3333, "csrJunk", 2)	&& Returns .T.
>WAIT WINDOW SEEK("3.30", "csrJunk", 3)		&& Returns .F. I expected a Data type mismatch error
>
>WAIT WINDOW SEEK(.T., "csrJunk", 1)		&& Error - Data type mismatch
>WAIT WINDOW SEEK({^2000/01/01}, "csrJunk", 1)	&& Error - Data type mismatch
>
>
>Why doesn't the third wait window cause an error like I think it should! Bug? By design?
>
>TIA
>Mike

It is not a bug, it is by design.

A nasty side effect is that:
CLEAR

CREATE cursor TEMP (Fld1 I)

INSERT INTO TEMP VALUES (100)      
INSERT INTO TEMP VALUES (0)      	&& every not numeric string found this !!!
INSERT INTO TEMP VALUES (113)      

INDEX ON Fld1 TAG Temp

SEEK [somestring]
? FOUND(),RECNO()					&& .T.
? SEEK(''),RECNO()					&& .T.
? INDEXSEEK('AASDADAS'),RECNO()		&& .T.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform