Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
My wish to VFP 7.0
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00484748
Message ID:
00485427
Views:
13
Bill,
I agree with Erik. I've not come accross many situations where I needed macro substitution in VB. We need it in VFP when using commands such as SELECT SQL, REPLACE, etc.
*-- for example to build a SQL SELECT command dynamically in VFP, we need something like this:

MyField = "Id"
MyTable = "FoxUser"
MyWhere = " WHERE Id LIKE 'WIND%'"

SELECT &MyField FROM (MyTable) &MyWhere

*-- however, when we use SPT, we can build the SQL command and pass the
*-- string to SQLEXEC():

*-- build the SQL command
lcSqlCommand = "SELECT " + MyField + " FROM " + MyTable + " " + MyWhere

SQLEXEC(lnSQL, lcSqlCommand)

*-- same approach with ADO:
ioRecordSet.Open(lcSqlCommand, This.ioConnection, adOpenDynamic, adLockOptimistic)
It would be nice if we could use SQLEXEC() against local data.

>Hi Erik,
>
>>>I know this may sound like heresy to some, but I make extensive use of VFP's ability to execute &-macro defined command lines. This is an extremely powerful feature that sets VFP apart from any other language I know of.
>>
>>Just for debate's sake, could you give an example of one of these uses? I have yet to see a good one...
>
>What about dynamic SQL? You could want to retrieve all the Paid claims, optionally only for one Provider.
>local lcSql
>
>lcSql = "SELECT * FROM Claim " ;
>      + "WHERE Claim_Status = 'PAID' "
>
>if !empty(ThisForm.txtProviderNumber.Value)
>   lcSql = lcSql + "AND Provider_Number = " ;
>         + ltrim(str(ThisForm.txtProviderNumber.Value))
>endif
>
>&lcSql INTO CURSOR csrClaimData
>
>Or did I misunderstand your question...
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform