CREATE GENERATOR GTBGP_ETAPA_PMP_COLUNA_ITEM;

CREATE TABLE TBGP_ETAPA_PMP_COLUNA_ITEM (
    ID                      INTEGER NOT NULL,
    GP_ETAPA_PMP_COLUNA_ID  INTEGER,
    DESCRICAO               VARCHAR(150),
    VALOR                   INTEGER,
    ORDEM                   INTEGER,
    DATAHORA                TIMESTAMP DEFAULT 'NOW'
);

ALTER TABLE TBGP_ETAPA_PMP_COLUNA_ITEM ADD CONSTRAINT PK_TBGP_ETAPA_PMP_COLUNA_ITEM PRIMARY KEY (ID);

CREATE OR ALTER TRIGGER TTBGP_ETAP_PMP_COL_ITEM_B01I FOR TBGP_ETAPA_PMP_COLUNA_ITEM
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbgp_etapa_pmp_coluna_item,1);
end;