CREATE TABLE TBBI_PAINEL (
    ID INTEGER NOT NULL,
    DESCRICAO VARCHAR(50),
    OBSERVACAO VARCHAR(100),
    STATUS INTEGER DEFAULT 0);

ALTER TABLE TBBI_PAINEL
ADD CONSTRAINT PK_TBBI_PAINEL
PRIMARY KEY (ID);

CREATE SEQUENCE GTBBI_PAINEL;

create trigger ttbbi_painel_b01i for tbbi_painel
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbbi_painel,1);
end;

COMMENT ON TABLE TBBI_PAINEL IS 'tabela de paineis de Inteligencia de Negocios';

CREATE TABLE TBBI_PAINEL_SQL (
    ID INTEGER NOT NULL,
    DESCRICAO VARCHAR(30),
    SQL BLOB SUB_TYPE 1 SEGMENT SIZE 80,
    PAINEL_ID INTEGER,
    STATUS INTEGER);

ALTER TABLE TBBI_PAINEL_SQL
ADD CONSTRAINT PK_TBBI_PAINEL_SQL
PRIMARY KEY (ID);

CREATE SEQUENCE GTBBI_PAINEL_SQL;

create trigger ttbbi_painel_sql_b01i for tbbi_painel_sql
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbbi_painel_sql,1);
end;

COMMENT ON TABLE TBBI_PAINEL_SQL IS 'tabela de sqls do painel de bi';

