Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Construct SELECT statement in runtime
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00026756
Message ID:
00026828
Vues:
30
>I have a form which allows user to input a combination of criteria and then I need to construct a SELECT statement in runtime using the user criteria.
>
>Initially how I solve the problem is to create a QPR file runtime by using file I/O function. Then in my program, I DO the constructed QPR file.
>
>However, It only works when I run my program under VFP. It won't work if I build an EXE because the QPR file is built in the EXE at compile time and I cannot change it in runtime.
>
>Any comments/suggestions will be highly appreciated!
>
>Thanks!

Here is an example of a dynamic sql:

*-
*- Setup the SQL statement parms.
*-
lcLUFields = this.LUFields
lcLUTable = this.LUTable
lcLUCursor = this.LUCursor
lcSQLWhere = this.SQLWhere
lcSQLOrderBy = this.SQLOrderBy
*-
if empty(lcSQLWhere)
lcSQLWhere = 'where "" = ""'
else
lcSQLWhere = 'where ' + lcSQLWhere
endif
if empty(lcSQLOrderBy)
lcLUKeyField = this.LUKeyField
else
lcLUKeyField = lcSQLOrderBy
endif
*- Check to see if the Temp LU is used.
if !this.LUGrid
*- Check for empty parms.
if inlist('',lcLUFields, lcLUTable, ;
lcLUCursor, lcLUKeyField)
wait window 'Empty SQL parameter was passed to ' ;
+ alltrim(this.name) + '.init()' ;
timeout SEC_LONG_WAIT
*-
return(FALSE)
endif
endif
*-
*- Setup the SQL statement.
*-
this.rowsource = ;
'select &lcLUFields ;
from &lcLUTable ;
&lcSQLWhere ;
into cursor &lcLUCursor ;
order by &lcLUKeyField'
Tom
--------------------------------
Tom O'Hare
407-299-4268 -- tom@redtile.com -- http://www.redtile.com/
Independent Programmer Using Visual FoxPro, Visual Basic & more...
Operations Manager -- Virtual FoxPro User Group (VFUG)
http://www.vfug.org/ -- tom@vfug.org
President -- Central Florida FoxPro User Group (CFFUG)
http://www.redtile.com/foxpro/
Universal Thread Most Valued Professional (MVP)
http://www.transformation.com/foxpro/
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform