[SOLVED] Why this SQL isn't prepared? lazarus / 16-Databases ---------------------------------------------------------------------- egsuh · 2020-06-02 06:43 Hello, Please look into the following statements. This SQL works well if I directly execute it within Firebird, e.g. through FlameRobin, etc. But in Lazarus, the "Prepare" command is not executed. I cannot find any reason. What would be possible reasons? 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  with qr2 do begin      Close;      SQL.Clear;      SQL.Text := 'insert into SampleList ';      SQL.Add('(project_id, solicitor_id, respondent_id, keycode, email, pw, interviewer_id, status) ');      SQL.Add(' values (:pid, :sid, :rid, :kc, :em, :pw, :iid, :ss)');      SQL.Add(' returning respondent_id');       Log(sql.text);       Prepare;      Log('prepared'); ---------------------------------------------------------------------- rvk · 2020-06-02 06:49 How do you know, from the code shown, that the statement isn't prepared? ---------------------------------------------------------------------- egsuh · 2020-06-02 06:58 Ah..  the procedure Log writes the string to a file. SQL.Text is logged, but 'prepared' not. ---------------------------------------------------------------------- rvk · 2020-06-02 07:01 Quote from: egsuh on June 02, 2020, 08:58:33 amAh..  the procedure Log writes the string to a file. SQL.Text is logged, but 'prepared' not. You've shown too little code. If this is your exact code, all lines should be executed. Unless Log(sql.text) gives an exception. (Or prepare gives an exception because of an error in the sql.text) ---------------------------------------------------------------------- Zvoni · 2020-06-02 08:32 Out of curiosity: How can an SQL-Statement be prepared with unset parameters? ---------------------------------------------------------------------- rvk · 2020-06-02 08:41 Quote from: Zvoni on June 02, 2020, 10:32:18 amOut of curiosity: How can an SQL-Statement be prepared with unset parameters? With "unset parameters"? What's an unset parameter. Prepare is best used with a parameterized statement which executes multiple times. It doesn't do much for a single statement because internally there a prepare is always done automatically. Also see https://firebirdsql.org/file/documentation/third_party_docs/Make%2520I nterbase%2520Scream.pdf ---------------------------------------------------------------------- egsuh · 2020-06-02 08:55 I found the reason ... when there is a field name not in the table, the sql is not prepared. That is, field pw was not in the table samplelist. Well I thought that in that case, the exception would be raised at the "opening" stage. ---------------------------------------------------------------------- rvk · 2020-06-02 08:59 Quote from: egsuh on June 02, 2020, 10:55:55 amWell I thought that in that case, the exception would be raised at the "opening" stage. Yes, there should have been an exception. But maybe your 'eating' that exception at a higher level. You could build a try/except/showmessage around the prepare to make sure.