These steps what I have tried so far without success. (Note: Firebird embedded does not seem to require quotes around names like HSQLDB but also seems inconsistent?) What am I doing wrong?
*1 Create a table in the a LibreOffice Firebird embedded database called “phonecalls” … (this works)
CREATE TABLE "phonebook" ( "id_pn" INTEGER NOT NULL PRIMARY KEY, "phone_number" VARCHAR(16), "name" VARCHAR(128), "date" DATE, "note" VARCHAR(256), "flag" VARCHAR(2) );
*2 Create auto-increment ID generator… (seems to work, but can’t verify if the generator has been created)
CREATE GENERATOR GEN_PHONEBOOK_ID; SET GENERATOR GEN_PHONEBOOK_ID TO 0;
*3 Create TRIGGER to auto-increment the generator… (does NOT work)
set term !! ; CREATE TRIGGER TRIG_PHONEBOOK_AUTOINC FOR PHONECALLS ACTIVE BEFORE INSERT POSITION 0 AS BEGIN if (NEW.ID is NULL) then NEW.ID = GEN_ID(GEN_PHONEBOOK_ID, 1); END!! set term ; !!
*4 Try to get auto-increment generator value… (does not work…)
SELECT GEN_ID( GEN_PHONEBOOK_ID, 0 ) FROM PHONECALLS;