Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro substitution and evaluate - which to use
Message
 
 
À
19/07/2007 14:03:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01241954
Message ID:
01242088
Vues:
24
>>>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
>>
>>AFAIK it would not work in fields clause and in where clause. You do have to use macro.
>
>Name substitution definitely works in the field list when you're specifying a single field. To substitute an expression in the WHERE clause, you do need a macro.
>
>Tamar

You replied while I were updating my message with a test.

Anyway, see:
CREATE CURSOR curTest (cField C(10))
INSERT INTO curTest VALUES ('AAAAAAA')
lcField = 'cField'
lcNewField = 'NewField'
SELECT (m.lcField) as (m.lcNewField) FROM curTest
SELECT &lcField as (m.lcNewField) FROM curTest
SELECT evaluate(m.lcField) as (m.lcNewField) FROM curTest
I would assume Beth would prefer the second form since evaluate will work on every record and be much slower in this case than macro substitution.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform