Italian community of Lazarus and Free Pascal

Programmazione => Generale => Topic aperto da: petrusic - Giugno 25, 2024, 12:14:22 pm

Titolo: Select Query con Union, in SQlite3 non funziona, in Debug
Inserito da: petrusic - Giugno 25, 2024, 12:14:22 pm
Questa mattina, a partire, da una delle prove avviate, la seguente Select non vuole funzionare più:
Codice: [Seleziona]
  sql:= 'Select * From (Select "causalifreq" AS nomeTbx, count(*) AS totRecTbx from causalifreq';
  sql:= sql + ' UNION Select "ggaperte" AS nomeTbx, count(*) AS totRecTbx from ggaperte';
  sql:= sql + ' UNION Select "movimgg" AS nomeTbx, count(*) AS totRecTbx from movimgg';
  sql:= sql + ' UNION Select "partmovv" AS nomeTbx, count(*) AS totRecTbx from partmovv';
  sql:= sql + ' UNION Select "piancont" AS nomeTbx, count(*) AS totRecTbx from piancont';
  sql:= sql + ' UNION Select "prestmom" AS nomeTbx, count(*) AS totRecTbx from prestmom';
  sql:= sql + ' UNION Select "racodvoci" AS nomeTbx, count(*) AS totRecTbx from racodvoci';
  sql:= sql + ' UNION Select "restacassagg" AS nomeTbx, count(*) AS totRecTbx from restacassagg';
  sql:= sql + ' UNION Select "riepmovg" AS nomeTbx, count(*) AS totRecTbx from riepmovg';
  sql:= sql + ' UNION Select "componfam" AS nomeTbx, count(*) AS totRecTbx from componfam';
  sql:= sql + ' UNION Select "riepnewrecdb" AS nomeTbx, count(*) AS totRecTbx from riepnewrecdb) AS contaRecDB';
 WriteLn('sql= ~' + sql + '~');
  DataModule1.ZConnection1.Database:= dbCorr;
  DataModule1.ZConnection1.Connected:= True;
  DataModule1.ZReadOnlyQuery1.Active:= False;
  DataModule1.ZReadOnlyQuery1.SQL.Text:= sql;
  DataModule1.ZReadOnlyQuery1.Active:= True;        // <------   qui va in ERRORE
  DataModule1.ZReadOnlyQuery1.First;
  while not DataModule1.ZReadOnlyQuery1.EOF do
  begin
    i:= 0;
    striMia:= DataModule1.ZReadOnlyQuery1.FieldByName('nomeTbx').AsString;
    while not swFine do
    begin
      if (tbDBintegro[i, 0] = striMia) then
      begin
        tbDBintegro[i, 1]:= DataModule1.ZReadOnlyQuery1.FieldByName('totRecTbx').AsString;
        break;
      end;
      i:= i + 1;
    end;
    DataModule1.ZReadOnlyQuery1.Next;
  end;

L'Errore che ne viene fuori è:
Citazione
SQL Error: SQL logic error.

Il codice NON  è stato assolutamente modificato, nè oggi, nè ieri.
Tuttavia, per mia tranquiillità, ho ripreso sul file salvato ieri sera ed hoi ripetutoi la prova. Ebbene, l'ERRORE, in prova, c'è sempre.

Inoltre, la stranezza è che, eseguendo il programma già compilato, l'Errore non viene segnalato.

Non so se qualcuno ha vissuto un'esperienza come la mia attuale. A me è la prima volta che succede un patimento del genere.





Titolo: Re:Select Query con Union, in SQlite3 non funziona, in Debug
Inserito da: petrusic - Giugno 25, 2024, 02:41:32 pm
Inspiegabile. Ha ripreso a funzionare!.
 ???
Titolo: Re:Select Query con Union, in SQlite3 non funziona, in Debug
Inserito da: DragoRosso - Giugno 25, 2024, 05:41:22 pm
Hai aggiornato Lazarus e Zeos ?