Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to specify a list of values in a where clause of a v
Message
 
 
À
03/03/2008 11:19:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01298171
Message ID:
01298172
Vues:
28
Sylvain,

Please check

Re: Macro Substitution in Views Thread #981881


>I need to filter a view on a variable list of values, but I wonder what's the best approach. Here's the SELECT-SQL we used before:
lcList = "ABC,DEF,GHI"
>SELECT * FROM MyTable WHERE MyField $ m.lcList
I'm trying to build a view based on this, with lcList specified at run-time, but the view designer won't let me use the $ operator.
>
>I tried the In operator, but it give me a syntax error when trying to save the view. If I copy-paste the SQL generated by the view in the command window, it work without problems. Here's the resulting SQL of the view:
lcList = '"ABC,DEF,GHI"'
>SELECT * FROM MyTable WHERE MyField IN (&lcList)
I found a way to make it work, but it require that I create a cursor, which is more work and less usable:
CREATE CURSOR curFilter (MyField C (10))
>INSERT INTO curFilter (MyField) VALUES ("ABC")
>INSERT INTO curFilter (MyField) VALUES ("DEF")
>INSERT INTO curFilter (MyField) VALUES ("GHI")
>SELECT * FROM MyTable WHERE MyField IN (SELECT MyField FROM curFilter)
Is there a way of making my original view work (with the character variable) or better yet, use the $ operator in a view?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform