SQLdb ParseSQL lazarus / 16-Databases ---------------------------------------------------------------------- valdir.marcos · 2018-09-04 13:02 How can I see the automatically generated commands for SQLQuery1.InsertSQL, SQLQuery1.UpdateSQL and SQLQuery1.DeleteSQL after setting SQLQuery1.ParseSQL? I have attached a very small sample project. 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 procedure TForm1.Button1Click(Sender: TObject);begin  SQLQuery1.Close;  SQLQuery1.SQL.Text := 'Select ID, Name, Age From People ' + LineEnding +                        'Order By ID;';  SQLQuery1.ParseSQL := True;  SQLQuery1.Open;   Memo1.Text := SQLQuery1.InsertSQL.Text;  Memo2.Text := SQLQuery1.UpdateSQL.Text;  Memo3.Text := SQLQuery1.DeleteSQL.Text;   Memo4.Clear;  SQLQuery1.First;  while not SQLQuery1.EOF do  begin    Memo4.Lines.Add(SQLQuery1.FieldByName('ID'). AsString + ', ' +                  SQLQuery1.FieldByName('Name'). AsString + ', ' +                  SQLQuery1.FieldByName('Age'). AsString + '.');    SQLQuery1.Next;  end;  SQLQuery1.Close;  SQLTransaction1.Commit;end; ---------------------------------------------------------------------- mangakissa · 2018-09-04 15:08 Isn't there a Firebird monitoring component is SQLdb tab? ---------------------------------------------------------------------- valdir.marcos · 2018-09-04 16:29 Quote from: mangakissa on September 04, 2018, 05:08:50 pmIsn't there a Firebird monitoring component is SQLdb tab?Yes, there is and I can see that information through monitoring tables on Firebird. The question here is if the component generates and uses that information, why can't I see it? ---------------------------------------------------------------------- rvk · 2018-09-04 21:02 As far as I can see from the sources is that those updatesql statements are generated, used and freed only internally. There is no access to the statements themselves. You can use a monitor component to see them but only at the moment you issue an insert, update or delete on the table. The internal statements are not created during parsesql but dyring the actual .insert/.edit/.delete. What do you need it for? You could generate those statements yourself (you can even look at the sources how it's done). ---------------------------------------------------------------------- valdir.marcos · 2018-09-05 10:49 Quote from: rvk on September 04, 2018, 11:02:23 pmWhat do you need it for?I don't need the commands per se, I am just investiganting a bigger problem. I am trying to understand why those commands work correctly on an isolated test application, but on an actual application sometimes the same form leads to the error message below: -------------- Project xxx raised exception class 'EDatabaseError' with message: IBConnection1 : No update query specified and failed to generate one. (No fields for inclusion in where statement found) -------------- ---------------------------------------------------------------------- rvk · 2018-09-05 11:14 Quote from: valdir.marcos on September 05, 2018, 12:49:03 pmQuote from: rvk on September 04, 2018, 11:02:23 pmWhat do you need it for?I don't need the commands per se, I am just investiganting a bigger problem. I am trying to understand why those commands work correctly on an isolated test application, but on an actual application sometimes the same form leads to the error That's probably because you are using a complex SQL with JOINs. In that case FPC can't generate an updateSQL and you'll need to provide one manually. Or you have a SQL where FPC can't determine what fields should be used for updating a record. ---------------------------------------------------------------------- valdir.marcos · 2018-09-05 12:13 Quote from: rvk on September 05, 2018, 01:14:18 pmQuote from: valdir.marcos on September 05, 2018, 12:49:03 pmQuote from: rvk on September 04, 2018, 11:02:23 pmWhat do you need it for?I don't need the commands per se, I am just investiganting a bigger problem. I am trying to understand why those commands work correctly on an isolated test application, but on an actual application sometimes the same form leads to the error That's probably because you are using a complex SQL with JOINs. In that case FPC can't generate an updateSQL and you'll need to provide one manually. Or you have a SQL where FPC can't determine what fields should be used for updating a record.It's not that obvious. I am talking about simple tables with less than 10 fields and only one field for primary key and no JOINs. And the worse part is that it happens randomly. I'll keep investigating. ---------------------------------------------------------------------- rvk · 2018-09-05 12:18 Quote from: valdir.marcos on September 05, 2018, 02:13:36 pmI am talking about simple tables with less than 10 fields and only one field for primary key and no JOINs. And the worse part is that it happens randomly. I'll keep investigating. If it's happening on a simple SELECT * FROM TABLE then you might want to add a primary key to the table and set Upda]"]>Blockedde to upWhereKeyOnly. If it's set to upWhereAll or upWhereChanged, FPC might not be able to create a correct updatesql. With upWhereKeyOnly and the primary key part of the select it should always work fine. ---------------------------------------------------------------------- valdir.marcos · 2018-09-05 12:26 Quote from: rvk on September 05, 2018, 02:18:48 pmWith upWhereKeyOnly and the primary key part of the select it should always work fine.This is the problem: it should work, but randomly it does not. So, I am setting everything manually as a workaround.