>>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