CREATE GENERATOR GTBFIREBIRD_ADMIN_DB_NF;

CREATE TABLE TBFIREBIRD_ADMIN_DB_NF (
    ID             INTEGER,
    DESCRICAO      VARCHAR(50),
    SERVIDOR_TIPO  INTEGER,
    SERVIDOR       VARCHAR(50),
    PROTOCOLO      INTEGER,
    DB             VARCHAR(100),
    USUARIO        VARCHAR(30),
    SENHA          VARCHAR(30),
    CHAR_SET       VARCHAR(20),
    PASTA_ID       INTEGER,
    EMPRESA_DIR    VARCHAR(30),
    EMPRESA_ID     INTEGER,
    PRINCIPAL      INTEGER
);

SET TERM ^ ;

CREATE OR ALTER TRIGGER TTBFIREBIRD_ADMIN_DB_NF_B01I FOR TBFIREBIRD_ADMIN_DB_NF
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbfirebird_admin_db_NF,1);
end
^

SET TERM ; ^

CREATE GENERATOR GTBFIREBIRD_ADMIN_DB_FILES;

CREATE TABLE TBFIREBIRD_ADMIN_DB_FILES (
    ID             INTEGER,
    DESCRICAO      VARCHAR(50),
    SERVIDOR_TIPO  INTEGER,
    SERVIDOR       VARCHAR(50),
    PROTOCOLO      INTEGER,
    DB             VARCHAR(100),
    USUARIO        VARCHAR(30),
    SENHA          VARCHAR(30),
    CHAR_SET       VARCHAR(20),
    PASTA_ID       INTEGER,
    EMPRESA_DIR    VARCHAR(30),
    EMPRESA_ID     INTEGER,
    PRINCIPAL      INTEGER
);

SET TERM ^ ;

CREATE OR ALTER TRIGGER TTBFIREBIRD_ADMIN_DB_FILES_B01I FOR TBFIREBIRD_ADMIN_DB_FILES
ACTIVE BEFORE INSERT POSITION 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbfirebird_admin_db_FILES,1);
end
^

SET TERM ; ^