Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning all records with an SQL statement
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00582293
Message ID:
00582381
Vues:
32
We use the following query in production now. It has a mixture of macro sub and () evals in select clauses. we build the selection clauses elsewhere and the where filter. A lot of the stuff is data driven like getting the 3 letter alias from a table to build the field selection ( e.g. ans.fieldname) etc...
It works good so far...

IF !EMPTY(thisform.c_WhereFilt)
lcWhere = 'WHERE ' + thisform.c_WhereFilt && built in another method
ELSE
lcWhere = ''
ENDIF

IF !EMPTY(thisform.c_AnsFields)
lcAnsFields = thisform.c_AnsFields && built in another method
ELSE
lcAnsFields = ''
ENDIF


* set the join condition based on the user selection
DO CASE
CASE thisform.l_AllTestPoints
lcTstAnsJoin = 'LEFT OUTER JOIN '
CASE thisform.l_ReadingOnly
lcTstAnsJoin = 'INNER JOIN '
OTHERWISE
lcTstAnsJoin = 'INNER JOIN '
ENDCASE

lcSelCursor = sellist() && get the select cursor name

SELECT tst.*, ;
&lcAnsFields ;
tsf.location, ;
tsf.equation, ;
tsf.legal ;
FROM tstpoint tst ;
INNER JOIN tstfac tsf ;
ON &gcTsfTstJn ; && constant define join condition
(lcTstAnsJoin) ansurvey ans ;
ON &gcTstAnsJn ; && constant define join condition
INNER JOIN nodes nde ;
ON nde.ndesyscode = tsf.sys_code ;
INNER JOIN &lcSelCursor sel ;
ON tsf.sys_code + tsf.pipe = sel.sys_code + sel.pipe ;
&lcWhere ;
INTO CURSOR cAnsreads NOFILTER


MW
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform