CREATE TABLE TBGNRE (
    ID INTEGER NOT NULL,
    GNRE_RECEITA_ID INTEGER,
    GNRE_DET_RECEITA_ID INTEGER,
    GNRE_CLASS_PROD_ID INTEGER,
    GNRE_TIPO_DOCUMENTO_ID INTEGER,
    CONVENIO VARCHAR(200),
	DATA_PAGAMENTO DATE,
    USUARIO_ID INTEGER,
    DATAHORA TIMESTAMP DEFAULT 'NOW');

ALTER TABLE TBGNRE
ADD CONSTRAINT PK_TBGNRE
PRIMARY KEY (ID);

CREATE SEQUENCE GTBGNRE;

SET TERM ^ ;

create trigger ttbgnre_b01i for tbgnre
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbgnre,1);
end
^

SET TERM ; ^

ALTER TABLE TBGNRE_NF
    ADD GNRE_ID INTEGER DEFAULT 0 NOT NULL;

CREATE INDEX ITBGNRE_NF_10
ON TBGNRE_NF (GNRE_ID);