Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using an Expression to Get the Field Name..
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00282481
Message ID:
00282527
Vues:
25
When I Try SELECT &MyField FROM MyTable INTO CURSOR curSQLCursor WHERE &MyField LIKE "Z%"

I get a Syntax Error.

If I Store the SQL in a String How to I Execute it? I've tried EVAL and EVALUATE by get Syntax Errors there too, Here's an Example of What I'm Trying to Achieve..

LOCAL lcField
LOCAL lcTable

m.lcField = "Field1"
m.lcTable = "Table1"

SELECT m.lcField FROM m.lcTable INTO CURSOR curSQLCursor WHERE m.lcField LIKE 'Z%'

Where Field1 in Table1 Contains "Zebra" for example.

Going bald fast here.

>Try this:
>
>SELECT &MyField FROM (MyTable) WHERE &MyField LIKE "Z%" INTO CURSOR curSQLCursor
>
>HTH
>I'm trying to write some code which will Open a Table and Perform a SQL Statement On it using Paramters passed in, so nothing is Hardcoded/set at Design Time.
>>
>>My problem arrises when I try to use a SELECT statement, specifying the Fields I want to Select and the fields I wish to Compare in my WHERE Clause. If I pass a variable, (containing the field Name), it doesn't work, eg.
>>
>>SELECT m.MyField FROM m.MyTable INTO CURSOR curSQLCursor WHERE m.MyField LIKE 'Z%'
>>
>>In the above Statement, it treats m.MyField as a Literal, instead of substituting it for the Value held by the m.MyField Variable.
Aaron Young
Red Wing Software, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform