Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select statement returns all records
Message
 
À
16/03/2001 07:46:13
Sammy Derban
Ghana Telecom
Accra, Ghana
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00485792
Message ID:
00485822
Vues:
7
>Hello all,
>My 'Select' statement returns all records when the key field is blank ie ""
>The table key field is character. set Exact is on. Vfp 5
>Any help?
>
>Samlpe code:
>SELECT RES_CODE, RES_NAME, RUNIT_CODE FROM RES_REC INTO ARRAY RECARRAY ;
>WHERE rec_no = alltrim(thisform.txtrecno.value)

A value of "" matches all records. It is not a bug. It basically states find all records where the rec_no starts with "". And all records start with nothings.

If you wish to search on only those fields that the user enters data in, then I would build a where clause using a CASE or IF statement.
lcWhere = ''
llAndFlag = .F.
IF NOT EMPTY(thisform.txtrecno.value)
  lcWhere = 'rec_no = ' + alltrim(thisform.txtrecno.value)
  llAndFlag = .T.
ENDIF
IF NOT EMPTY(some.other.field.value)
  IF llAndFlag
    lcWhere = 'AND some_other_field = ' + alltrim(some.other.field.value)
  ELSE
    llAndFlag = .T.
    lcWhere = 'some_other_field = ' + alltrim(some.other.field.value)
  ENDIF
ENDIF
Etc...
HTH
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform