Hi Bernhart,
Don't be fooled on reports that macro substitution is slower. It is in the order of microseconds per programline call. For a SQL statement you'll not notice any performance difference between hardcoding the whole SQL statement and using marcosubstitution.
Using EVAL() in these cases is much, much worse. If used in the where clause it is called for every record processed. With thousands of records, this really kills the performance of your query. When using macrosubstituation, the macro is evaluated and the whole statement is compiled at runtime. Compiling the whole statment costs a little time (microseconds) but after that VFP handles it just like hard coded statments. EVAL() passes its argument to the compiler and runs it for every time the EVAL function is called. If mutiple records are processed here, the EVAL() function is run for every record, making it a real performance killer with large amounts of records.
In general you could say that in every statment where the argument could be evaluated more than once (DO WHILE, SCAN, SET FILTER TO, REPLACE NEXT/REST/FOR/WHILE, LOCATE FOR etc) macros would be best. In every statment which argument is only evaluated once the EVAL() function has a performance advantage. However in the latter, you'll only notice it when having a lot of iteration of these statements.
Walter,
>Hi all?
>
>When i try this code i haven't error.
>
>
>dvd = DATE()
> ccondit = ' ?dvd BETWEEN E.Ddebut AND E.Dfin '
>
> SELECT Teleph.cnomteleph AS 'cnom' , e.ddebut ;
> FROM ( ( amline!Resident AS 'R' ;
> INNER JOIN amline!Teleph Teleph ON R.itelephoneid = Teleph.iid ) ;
> LEFT OUTER JOIN amline!Etats AS 'E' ON R.iid = e.iresidentid );
> WHERE &ccondit ORDER BY 1 INTO CURSOR Temp
>
>
>When i try this Code i have a syntax error !
>
>dvd = DATE()
> ccondit = ' ?dvd BETWEEN E.Ddebut AND E.Dfin '
>
> SELECT Teleph.cnomteleph AS 'cnom' , e.ddebut ;
> FROM ( ( amline!Resident AS 'R' ;
> INNER JOIN amline!Teleph Teleph ON R.itelephoneid = Teleph.iid ) ;
> LEFT OUTER JOIN amline!Etats AS 'E' ON R.iid = e.iresidentid );
> WHERE EVAL( ccondit ) ORDER BY 1 INTO CURSOR Temp
>
>
>
>Why ?
>I want to use the command 'evaluate' because it appears that faster ?
>
>bernhart