CREATE TABLE ITEM_ENTRADA (
ID_ITEM_ENTRADA INTEGER NOT NULL PRIMARY KEY,
ID_ENTRADA INTEGER NOT NULL,
ID_ITEM INTEGER NOT NULL,
QTD INTEGER NOT NULL
);

CREATE GENERATOR GEN_ID_ITEM_ENTRADA ;

SET TERM ^;

CREATE TRIGGER TRIG_GEN_ID_ITEM_ENTRADA FOR ITEM_ENTRADA
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
   NEW.ID_ITEM_ENTRADA = gen_id(GEN_ID_ITEM_ENTRADA,1);
END
^

COMMIT WORK^
SET TERM;^
