firebird , lazarus and auto inc field problems [SOLVED] lazarus / 16-Databases ---------------------------------------------------------------------- timcs · 2013-06-05 07:58 Hi   I could not seem to find this as an existing post so sorry if my searching is poor .  I have set up a basic program just to insert records into a firebird database which I created from a program called FB Explorer. This dataase has a table called links and a auto inc field called ID. Reading up on creating an auto in field in firebird I followed this guide: http://www.firebirdfaq.org/faq29/ I did all of this in FB Explorer and this worked as I tested it by creating a new record in this program which incremented the ID whereas before hand it errored without the trigger and generator being created. However since I have done this, (I was also getting the ID increment error in Lazarus as well before hand) lazarus/firebird are still giving me errors when creating a new record stating that the ID needs to be populated. this is how I am trying to create a new record in Lazarus : Code: [Select] if SQLQuery1.Active = true then      begin           SQLQuery1.Insert;           SQLQuery1.FieldByName('dateon').AsDateTime:= dateof(now);           SQLQuery1.FieldByName('timeon').AsDateTime:= timeof(now);           SQLQuery1.FieldByName('username').AsString:= edit1.Text ;           SQLQuery1.FieldByName('customer').AsString:= edit2.Text;           SQLQuery1.FieldByName('ipaddress').AsString:= edit3.Text;           SQLQuery1.FieldByName('IDLINK').AsInteger:= StrToInt(edit4.Text);           SQLquery1.Post;           user := edit1.text;           idlink := StrToInt(edit3.Text);      end;                                uses clauses : Code: [Select]uses   Classes, SysUtils, sqldb, db, IBConnection, FileUtil, Forms, Controls,   Graphics, DateUtils, Dialogs, DBGrids, DbCtrls, StdCtrls;    I did read one post here but that user was using a Zquery component. Thanks TimCS ---------------------------------------------------------------------- exdatis · 2013-06-05 08:43 See old posts: http://www.lazarus.freepascal.org/index.php/topic,16960.msg92990.html# msg92990 Regards ---------------------------------------------------------------------- timcs · 2013-06-05 08:48 Quote from: exdatis on June 05, 2013, 10:43:04 amSee old posts: http://www.lazarus.freepascal.org/index.php/topic,16960.msg92990.html# msg92990 Regards Read this but I am lost to what I need to do , the last post seems to relate to what I have done already against this database using the FB explorer Thanks TimCS ---------------------------------------------------------------------- timcs · 2013-06-05 21:13 Sorry I thought I had done the create view but now checking my database I didn't . So I have tried to run the view code via the FB explorer but I am getting an unknown token error when trying these various codes : Code: [Select]CREATE VIEW v_next_id (NEXT_ID) AS SELECT  GEN_ID(GEN_LINKS_ID, 1) FROM LINKS -> return new_id, set generator Code: [Select]CREATE VIEW v_next_id  (NEXT_ID) AS SELECT     GEN_ID(GEN_LINKS_ID, 1)   FROM RDB$DATABASE -> return new_id, set generator But with both attempts I get the following: QuoteInvalid token. Dynamic SQL Error. SQL error code = -104. Token unknown - line 5, column 12. Thanks TimCS ---------------------------------------------------------------------- timcs · 2013-06-05 22:23 Right found this post : http://www.lazarus.freepascal.org/index.php/topic,14462.msg76671.html# msg76671 Worked out to set the field required:=false; against the field in question this seems to be working now thanks Thanks TimCS