Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Macro substitution and evaluate - which to use
Message
From
19/07/2007 16:28:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/07/2007 13:45:16
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01241954
Message ID:
01242138
Views:
19
>>Hi All,
>>
>> I am trying to set up a select statement, I do not know the field name ahead of time. I do an AFIELDS() to get the field name, since there is only one field in the table. I need to change the field name to another name which I get before this select statement. I am thinks this way:
>>
>>SELECT EVALUATE(latmp[1]) as &lcnewfield. FROM &lcoldfile. ;
>>   INTO TABLE lcnewfile DATABASE &lcTAbleDbc.
>>
>>
>>Am I using the macro substitution too much? Can I do this easier? or nicer?
>
>In this case, neither EVAL() nor a macro is needed for most of what you're doing. Name substitution will do:
>
>
>SELECT (laTmp[1]) AS (lcNewField) ;
>  FROM (lcOldFile) ;
>  INTO TABLE lcNewFile DATABASE (lcTableDBC)
>
>
>I'm not 100% sure name substition works for the AS, but everywhere it will.
>
>Although most of the others recommend textmerge, I wouldn't bother in this case where name subsitution is enough. I find it much easier to read code that contains the actual SQL command than code that builds a string and executes it. While I haven't tested, I see no reason why this version would be slower.
>
>Tamar

Oh I was feeling alone:) Thanks.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform