Update/Insert SQLITE lazarus / 16-Databases ---------------------------------------------------------------------- Weitentaaal · 2021-09-07 14:04 Hello Guys , so i ran into this Problem : "No insert query specified and failed to generate one. (No fields found for insert- or update-statement found)" Here is My Code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  //Connection to Database{ ----- WGR Connect ----- }DB_WGR := TSQLite3Connection.Create(Nil);   TransWGR := TSQLTransaction.Create(DB_WGR);     DB_WGR.Transaction := TransWGR;    DB_WGR.DatabaseName := WGRPath;//DB_WGR.HostName := SQLiteDBHost; Todo//DB_WGR.UserName := SQLiteDBUser; TodoDB_WGR.Password := WGRPass;DB_WGR.Connected := true;DB_WGR.KeepConnection := true; //Init QueryRsBtWert := TSQLQuery.Create(Nil);RsBtText := TSQLQuery.Create(Nil);RsBtWert .Upda]"]>Blockedde:= upWhereAll;RsBtText .Upda]"]>Blockedde:= upWhereAll; //Function to Execute Query'sProcedure wgrExecute(var Recordset: TSQLQuery; Query: String);Begin  try     Recordset.Clear;     //Recordset := TSQLQuery.Create(nil);     Recordset.UsePrimaryKeyAsKey := False;     Recordset.DataBase := DB_WGR;     Recordset.PacketRecords := -1;     Recordset.SQL.Text := Query;     Recordset.Open;  except     on E : Exception do        Application.MessageBox(PChar('An Exception was raised : ' + E.Message), PChar('Error'), MB_ICONERROR);  end;End; //Save data to DBprocedure TSWData.SaveData();begin   wgrExecute(RsCalc, 'SELECT * FROM Geraet WHERE Zeichnung = ' + Trim((ZeichNr).toString) + ' AND KOMP=0 AND ART = 1 AND ZArtNum = ' + Trim((BtlArtNum).toString));   RsCalc.Edit;   RsCalc.FieldByName('SomeField').AsInteger := SomeValue;   RsCalc.FieldByName('SomeField').AsInteger := SomeValue;   RsCalc.FieldByName('SomeField').AsInteger := SomeValue;   RsCalc.FieldByName('SomeField').AsFloat := SomeValue;   RsCalc.FieldByName('SomeField').AsString := SomeValue;   RsCalc.Post;   RsCalc.ApplyUpdates;   TransWGR.CommitRetaining;    wgrExecute(RsBtWert, 'SELECT * FROM WERTE WHERE DATA = ' + Trim(DataNr.ToString));   RsBtWert.Edit;   wgrExecute(RsBtText, 'SELECT * FROM TEXTE WHERE DATA = ' + Trim(DataNr.ToString));   RsBtText.Edit;     RsBtWert.FieldByName('Para1').AsInteger := SomeValue;   RsBtText.FieldByName('Para1').AsString :=SomeValue;   RsBtWert.FieldByName('Para2').AsInteger := SomeValue;   RsBtText.FieldByName('Para2').AsString := SomeValue;    RsBtWert.Post;   RsBtWert.ApplyUpdates;   TransWGR.CommitRetaining; //--> just to test if inserting in "Werte" Table was successful (it was)   RsBtText.Post;   RsBtText.ApplyUpdates; //ERROR   TransWGR.CommitRetaining; end;  i do get the Error in Line: -->RsBtText.ApplyUpdates; i did the same Process with my Second Table (which stores Floats and Ints). Only difference is that this Table is Storing Strings. Here are the Objects if Needed (Only Listed the Values which are different, all other Values are the identical Except some Adresses but i guess they are always different): Objects After ".Post" Operation: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  FBLOBFIELDCOUNT = 0, (WERTE)FBLOBFIELDCOUNT = 50, (TEXTE)   Objects After ".ApplyUpdate" Operation: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  FBLOBFIELDCOUNT = 0, (WERTE)FBLOBFIELDCOUNT = 50, (TEXTE) FDISABLECONTROLSCOUNT = 0, (WERTE)FDISABLECONTROLSCOUNT = 1, (TEXTE) FRECORDSIZE = 411,FRECORDSIZE = 811, FUPDATEBLOBBUFFERS = $0,FUPDATEBLOBBUFFERS = $e1d03f8, FINSERTQRY = $ea768b8,FINSERTQRY = $0,   Fiels in Database are Text(255) / Integer / Float Any Help would be Appreciated I tried nearly everything and now i'm clueless  Thanks in advice ---------------------------------------------------------------------- balazsszekely · 2021-09-07 17:45 @Weitentaaal QuoteAny Help would be Appreciated I tried nearly everything and now i'm clueless  Hard to say...everything looks correct. However RsBtText does not know how to update table TEXTE and ask for an update query(property RsBtText.UpdateSQL), which makes me think that: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i wgrExecute(RsBtText, 'SELECT * FROM TEXTE WHERE DATA = ' + Trim(DataNr.ToString));returns more then one value. I also noticed that Upda]"]>Blockedde is upWhereAll, meaning you don't use primary keys. Besides the logical consistency issues, most RDBMS engines will benefit from including these primary keys(unique values, indexes, joins, etc...). Please consider to add primary keys to your table. ---------------------------------------------------------------------- Weitentaaal · 2021-09-08 05:42 Thats the Point, i can't My my boss does not want to change the Database bc the db is used by many dll's. When i started working here i did not see any Structured Database. i can change the Code but not the Database . However, I fixed it by manually inserting default values for each attribute in my database. There is no primary key or such in the table that affects the insertion. Thats the Code i added (Worked after inserted this, but "Data" did not have any different Properties (even if it should have them)):   RsBtWert.FieldByName('Data').AsInteger := DataNr; RsBtText.FieldByName('Data').AsInteger := DataNr; Edit: forgot to mention that "FINSERTQRY = $0" did have a Valid Adress after the Correction. Thanks @GetMem anyways for your Time, very appreciated ---------------------------------------------------------------------- Zvoni · 2021-09-08 06:50 Remove Line 63 in your first post? ---------------------------------------------------------------------- Weitentaaal · 2021-09-08 07:19 I did, it was just for a Test Case.