Subject MAKE 'EXECUTE STATEMENT' USE INDEX
Author Mr. John
HI,in SP I have this query

  FOR EXECUTE STATEMENT 'SELECT SUM(CANT)  FROM TABLE1 WHERE FIEL1='||:F1||' AND FIEL2='||:F2|| IIF(:pCondition=1,' AND FIEL3='||:F3,'')  INTO .. DO ..
 
 TABLE1 PK =FIELD1,FIELD2,FIELD3

 running the query gives a NATURAL PLAN

How to make it use the index?

Index is used if I change to:
    FOR SELECT SUM(CANT)  FROM TABLE1 WHERE FIEL1=:F1 AND FIEL2=:F2 AND FIEL3=:F3 INTO .. DO ..
but this way I can't use the IIF condition that I need

thanks!