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

Asked

Viewed 131 times

1

I have a problem adding a line to 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
  • What’s the matter with you?

  • @Ismael LIST OF BOUNDS (3)

  • See if this is it (remove 0): qryAgrupaValoresPorData.SQL[3] := clausulaIn;

  • You didn’t solve it, it was a mistake.

  • 1

    The way you are entering SQL is incorrect. You should use one of these ways: Query.SQL.Add('SQL_A_SER_INSERIDO'); // Add at end Query.SQL.Insert(Index, 'SQL_A_SER_INSERIDO'); // Add at desired line

  • @Wendelrodrigues sorry for the delay is that I changed the code again today. So I could solve I don’t know why else the query was empty.

Show 1 more comment

1 answer

1


Dude, I think the SQL which is in its component qryAgrupaValoresorData is different from the one you’re hoping will be there.

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 variable clausulaIn. It all seems to make a lot of sense, but the error shows that in SQL component no index line 3.

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

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

Hug.

  • So I had managed to solve, even put the comet in question. the query component was empty. But Thanks for the help

  • I took a look at the comments there, you said the query was empty. I think it would be a good thing if you put it because the query was empty and signal as solved. Hug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.