Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Macro substitution of SQL statement
Message
From
20/12/1998 10:02:52
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00168161
Message ID:
00169235
Views:
32
>Good Suggestion Dragan,
>
>I've changed my approach from:
>
>m.lcPath = AddBS("C:\December 1998")
>m.lcSQL = [SELECT * ] + [FROM ] + ForcePath( "entry.dbf", m.lcPath ) + [ INTO ARRAY aFees]
>
>*-- Execute SQL statement
>&lcSQL
>
>TO:
>
>m.lcPath = AddBS("C:\December 1998")
>*-- I've added a WHERE clause ONLY for clarity
>m.lcSQLWhere = [vendor="] + m.cVar + ["]
>
>SELECT * ;
>FROM ForcePath( "entry.dbf", m.lcPath ) ;
>WHERE &lcSQLWhere. ;
>INTO ARRAY aFees
>
>This seems to do the trick without much re-engineering.
>
>Thank you for your suggestion.
>
>P.S. It has been proven that my initial approach WILL work with both Win95 & Win98 but NOT with Win NT 4.0. I do not know about NT 3.51.

The trick was that you need the quotes around a string containing a long filename, or need a variable to contain that name. In your macro you had a string which evaluated into a line which contained a long filename without quotes around, and it was interpreted word by word, consequently giving syntax terror. You had several ways out:

m.lcSQL = [SELECT * FROM "] + ForcePath( "entry.dbf", m.lcPath ) + [" INTO ARRAY aFees]

(note the quotes around the filename), or

m.lcFileName = ForcePath( "entry.dbf", "C:\December 1998")
m.lcSQL = [SELECT * FROM (] + m.lcFileName + [) INTO ARRAY aFees]

(now it's a name expression containing a variable with full filename). You've done a mixture of these two to the same effect. Good that it works now, and you know where to look next time. HTH

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform