Delphi Add line in SQL error LIST OF BOUNDS (3)

1

I have a problem adding a line in my SQL LIST OF BOUNDS (3)

Delphi :
       clausulaIn := 'AND  A.NNUMEMAPAF IN (0';
      while not Q_Mapas.Eof do
      begin
           clausulaIn := clausulaIn + ',' + IntToStr(Q_MapasNNUMEMAPAF.AsInteger);
      Q_Mapas.next;
      end;

       clausulaIn := clausulaIn + ')';

       qryAgrupaValoresPorData.Close;
       qryAgrupaValoresPorData.SQL[03] := clausulaIn;
       qryAgrupaValoresPorData.ParamByName('EMPRESA').AsInteger := Form_Menu.Q_EmpresasNCODIGOEMPRE.AsInteger;
       qryAgrupaValoresPorData.Open;

My SQL:

SELECT A.DDTPGMVFMF DT_PAGTO, SUM(A.NVLPGMVFMF)
  FROM CORMVFMF A
 WHERE A.NCODIGOEMPRE = 2--:EMPRESA
  AND A.NNUMEMAPAF IN (0)
GROUP BY A.DDTPGMVFMF
 ORDER BY A.DDTPGMVFMF
    
asked by anonymous 28.04.2017 / 16:27

1 answer

1

Dude, I think the SQL that's in your qryAgrupaValoresorData component is different from the one you're expecting it to be in.

You expect to change the contents of the fourth line (the index line 3, since the count starts at 0) by the contents of the clausulaIn variable. Everything seems to make a lot of sense, but the error shows that in SQL of component there is no index line 3.

If I were in your place I would give a debug and check what the SQL content of the component is, and if I saw that it really is not the one you were expecting, I would check the code snippet that loads SQL into this query .

If this is the case try to put a little more information on the case, maybe I can help more.

Hug.

    
09.05.2017 / 18:05