CREATE TABLE ITEM_HISTORICO (
ID_ITEM_HISTORICO INTEGER NOT NULL PRIMARY KEY,
ID_ITEM INTEGER,
TIPO CHAR(1),
QTD INTEGER,
DESCRICAO VARCHAR(90),
USUARIO VARCHAR(10),
DATA DATE
);

CREATE GENERATOR GEN_ID_ITEM_HISTORICO;

SET TERM ^ ;

CREATE TRIGGER TRIG_GEN_ID_ITEM_HISTORICO FOR ITEM_HISTORICO
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
   NEW.ID_ITEM_HISTORICO = gen_id(GEN_ID_ITEM_HISTORICO,1);
END
 ^

COMMIT WORK ^
SET TERM ;^

