[solved] IBX Generated Field & Returning lazarus / 16-Databases ---------------------------------------------------------------------- Nicole · 2022-12-12 09:17 I thought this solved, but it is not. I use a TIBQuery and a IBUpdate and a IBDataset. Before my problem I only had the TIBQuery.So the both latter are just attempts to solve my current problem. And have a the primary key defined as returning field. I used the property genetator's Editor field as shown in the manual to define generator and primary key. It looks good. My  IBQuery_TradeInDB.Open; runs without exception. 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 idEintrag:=IBQuery_TradeInDB.ParamByName('id_trade').AsInteger; says "field not found". What is correct, because the field is not part of the query, but generated. My question: Which syntax will give me the returned primary-key = id_trade? (I suppose it is NOT ParamByName) ---------------------------------------------------------------------- rvk · 2022-12-12 10:23 I'm not sure how this is different from your other question. You also show very little code. What do you have in your IBQuery1.SQL.Text ? If it's an INSERT we've already discussed this in the other topic. We already said you can't use RETURNING in a TIBQuery where the INSERT SQL is in TIBQuery.SQL. You should use TIBSQL.SQL if you want returning. If it's a SELECT then you need to include id_trade in your SELECT fields and use 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 idEintrag:=IBQuery_TradeInDB.FieldByName('id_trade').AsInteger; ---------------------------------------------------------------------- Nicole · 2022-12-12 10:36 It is an insert, why else should I need a generator for a new primary key. And unfortunately I CANNOT include the primary key in the query, because Firebird will not accept it. The query ends by "returning id_trade", which is the primary key. The problem with IBSQL is the same as with IBQuery. I fear, if anybody does not know the answer, he will not know it with the other inserted fields by the SQL.text neither. ---------------------------------------------------------------------- Nicole · 2022-12-12 10:39 Quote from: Nicole on December 12, 2022, 11:36:40 amIt is an insert, why else should I need a generator for a new primary key. The difference to my previous question are an update-component, a generate-propterty and a DataSet. And unfortunately I CANNOT include the primary key in the query, because Firebird will not accept it. The query ends by "returning id_trade", which is the primary key. The problem with IBSQL is the same as with IBQuery. I fear, if anybody does not know the answer, he will not know it with the other inserted fields by the SQL.text neither. ---------------------------------------------------------------------- rvk · 2022-12-12 10:43 Quote from: Nicole on December 12, 2022, 11:36:40 amIt is an insert, why else should I need a generator for a new primary key. Then you should use TIBSQL, not TIBQuery. Quote from: Nicole on December 12, 2022, 11:36:40 amAnd unfortunately I CANNOT include the primary key in the query, because Firebird will not accept it. Uh, you can. I do it all the time (my code is from before there was RETURNING in Firebird). You can use a function to get a new id from the generator and use that included in your insert. Quote from: Nicole on December 12, 2022, 11:36:40 amThe problem with IBSQL is the same as with IBQuery. Then show the actual code. With TIBSQL and INSERT you need to use TIBSQL.ExecSQL and you get the RETURNING field with FieldByName. I already showed you the exact code in the other topic. But you keep posting about the same problem over and over again. Look at this post: https://forum.lazarus.freepascal.org/index.php/topi c,61505.msg463048.html#msg463048 You even replied that it works. Quote from: Nicole on December 08, 2022, 03:42:13 pmthank you all! It works. I did this (brute force and much luck) (...) ► the primary key is returned again ---------------------------------------------------------------------- Nicole · 2022-12-12 13:24 Thank you so much. I had re-tried the version with "update" from the IBX manual with my "old" IBQuery. It looked as it should work exactly for my case. Well, it did not under the finger-tipps of a DB-DAU. Now I went back to my version with the IBSQL and those code you posted, which I did not understand before. Thank you so much for your patience and re-linking it. Finally I read, Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Demo: Position wurde als "offen" in die DB eingetragen=294  294 is the id_trade,