how can I get the auto gen id of firebird after post operation? lazarus / 16-Databases ---------------------------------------------------------------------- bills · 2013-03-20 15:37 hi all,(sorry my english is poor) I encount a question: (firebird 2.5, lazarus1.1, fpc2.6, win7) 1.when i use dbf control and run insert then post operation,i can get the id: Code: [Select]dbf before post  ID: dbf after post  ID: 94 2. I use firebird,there is a table:person,it has a TRIGGER: Code: [Select]SET TERM ^ ; CREATE TRIGGER PERSON_BI FOR PERSON ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF (NEW.ID IS NULL) THEN   NEW.ID=GEN_ID(GEN_PERSON_ID,1); END^ SET TERM ; ^ I use  zeos to link to firebire:       ZConn: TZConnection;     ZQuery1: TZQuery; If I run insert then post operation,i cant get the id: Code: [Select]zeos Before Post ID: zeos After Post ID: how can I get the id after post if I use firebird db? here is some pics about this app: ---------------------------------------------------------------------- snorkel · 2013-03-20 16:10 Did you look at the sequencefield property? ---------------------------------------------------------------------- bills · 2013-03-20 22:01 Quote from: snorkel on March 20, 2013, 05:10:18 pmDid you look at the sequencefield property? No.I dont know the use of sequencefield. ---------------------------------------------------------------------- bills · 2013-03-21 02:07 Thank you snorkel, I try to use :   ZQuery1.SequenceField := 'ID';   ZSequence1.SequenceName := 'GEN_PERSON_ID';   ZQuery1.Sequence := ZSequence1;  and solved this problem. The 'GEN_PERSON_ID' is a GENERATOR name in birebird. I dont know why it use it. Because I have drop the TRIGGER. Thank you. The source code is blow: ---------------------------------------------------------------------- snorkel · 2013-03-22 01:01 Your welcome. It drops the trigger, but not the generator, in Firebird a generator is the same thing as a sequence in PostgreSQL or Oracle. The trigger just increments the generator for you. Later, Snorkel ---------------------------------------------------------------------- BigChimp · 2013-03-22 06:28 Quote from: snorkel on March 22, 2013, 02:01:52 amIt drops the trigger, but not the generator, in Firebird a generator is the same thing as a sequence in PostgreSQL or Oracle. OT: actually, in current Firebird, they're exactly the same. Sequence is the new (SQL standard name) for generator Apparently coming up in Firebird 3 are autoincrement fields (assuming they'll internally just use a trigger+seqence), but FB 3 is still in development.