Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable where clauses
Message
De
10/01/2005 16:30:07
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
00975797
Message ID:
00975820
Vues:
21
>>>Hi everybody,
>>>
>>>I have a cursoradapter class and would like to parameterize the where clause.
>>>
>>>1) Can this be done?
>>>2) How can I do this?
>>>
>>>Thanks in advance.
>>
>>1) Yes.
>>2) Like parametric views. Use ?Var for a parametric variable.
>>
>>Check Thread #944961
>>
>>Cetin
>
>Hi Cetin,
>
>I was just reading this thread. But we have more complicated situation. Basically, I have a search form, and I do not know which fields user is going to fill. I am working with VFP native data, though it doesn't make a difference. So, I need to be able to costruct "where" clause on the fly in the Cursor Adapter. Do you have suggestions how can we accomplish that?
>
>Thanks again.

You can pass builded WHERE clause as a parameter to CA. I think You have button which user press when finished fill Textfields Here You can build the where clause & pass it as a parameter to CA. Something like:
** Button Click
LOCAL cWhere
cWhere = ""
IF !EMPTY(thisform.Text1.Value)
   cWhere = "MyTable.Field1 = "+thisform.Text1.Value
ENDIF

IF !EMPTY(thisform.Text2.Value)
   cWhere = cWhere+IIF(EMPTY(cWhere),""," AND ")+ "MyTable.Field2 = '"+thisform.Text2.Value+"'"
ENDIF

etc..
myCa = CREATEOBJECT("CaClass", cWhere)


**** CA Init
LPARAMETERS cWhere

this.SelectCmd = "SELECT * FROM MyTable "+IIF(EMPTY(cWhere),""," WHERE "+cWhere)

...
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform