Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning all records with an SQL statement
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00582293
Message ID:
00582381
Views:
30
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform