Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL - set filter to
Message
De
09/03/2016 23:50:25
 
 
À
09/03/2016 23:08:05
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01632771
Message ID:
01632772
Vues:
57
>VERY interesting phenomenon - using a common data environment, using an SQL Select statement, after releasing the form it was called from, required a 'set filter to' statement to 'reset' the data to be able to 'seek' in it again without retaining a 'set filter to xyz' that was never issued! I have used SQL Select statements endlessly before, but nevvver with this result.
>
>ANY ideas??
>
>Thanks.


One of the disadvantages of "Set Filter" is that you might get errors when parts of a Set("Filter") expression somehow get out of scope --
like for example a variable or even something like a "Thisform.whatever.Value" expression.

SQL "Where" filters would not have that disadvantage, and are faster in scenarios where an alias gets displayed in a Grid (or in a Browse)


hth
-Stefan
* demo.PRG
CLEAR

* Test Data
CREATE CURSOR temp (nTest N(1), cTest C(1))
INSERT INTO temp VALUES (5, '5')

WAIT 'Filter expression containing a "name" seem to work:' WINDOW NOWAIT
LOCAL lnFilter
lnFilter = 5
SET FILTER TO nTest = m.lnfilter
? "SET('Filter'):", SET("Filter")
BROWSE && works because m.lnFilter is in scope

WAIT '... but does not if "name" is out of scope:' WINDOW NOWAIT
RELEASE lnfilter
BROWSE && Error 12

WAIT '&macro expressions work as if literals were typed directly in the editor:' WINDOW NOWAIT
LOCAL lcFilter
lcFilter = '5'
SET FILTER TO nTest = &lcFilter
RELEASE lcFilter
? "SET('Filter'):", SET("Filter")
BROWSE && works

LOCAL lcFilter
lcFilter = "'5'"
SET FILTER TO cTest = &lcFilter
RELEASE lcFilter
? "SET('Filter'):", SET("Filter")
BROWSE

LOCAL lcFilter
lcFilter = '5'
SET FILTER TO cTest = '&lcFilter'
RELEASE lcFilter
? "SET('Filter'):", SET("Filter")
BROWSE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform