CREATE TABLE TBMENU_APP_TABELA (
    ID INTEGER NOT NULL,
    TABELA VARCHAR(10),
    STATUS INTEGER,
    MENUS VARCHAR(100));

ALTER TABLE TBMENU_APP_TABELA
ADD CONSTRAINT PK_TBMENU_APP_TABELA
PRIMARY KEY (ID);

CREATE SEQUENCE GTBMENU_APP_TABELA;

SET TERM ^ ;

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

SET TERM ; ^

ALTER TABLE TBMENU_APP_TABELA
    ALTER TABELA TYPE VARCHAR(50) CHARACTER SET UTF8;

CREATE INDEX ITBMENU_APP_TABELA_02
ON TBMENU_APP_TABELA (TABELA);

CREATE INDEX ITBMENU_APP_TABELA_01
ON TBMENU_APP_TABELA (STATUS);

UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (13, 'TBCLIENTE_MODELO_PRECO', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (14, 'TBCLIENTE_PRODUTO_PRECO', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (18, 'TBEAN', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (20, 'TBFAMILIA', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (22, 'TBLOCALIZACAO', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (25, 'TBMODELO_COR', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (26, 'TBMODELO_LINHA', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (28, 'TBMOEDA_ESTRANGEIRA', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (32, 'TBOCORRENCIA_WEB_SQL', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (39, 'TBPEDIDO_ITEM', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (41, 'TBPERFIL_PEDIDO_CONF_USER', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (44, 'TBPRODUTO_PRECO', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (46, 'TBSUPERVISOR', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (47, 'TBTABELA_PRECO', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (51, 'TBUSUARIO_REPRESENTANTE', 0, NULL)
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (1, 'TBCLIENTE', 1, '1,2,3,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (10, 'TBUSUARIO', 1, '1,2,3,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (19, 'TBESTABELECIMENTO', 1, '1,2,3,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (45, 'TBREPRESENTANTE', 1, '1,2,3,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (15, 'TBCLIENTE_SUBTIPO', 1, '1,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (16, 'TBCLIENTE_TIPO', 1, '1,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (36, 'TBPAGAMENTO_CONDICAO', 1, '1,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (37, 'TBPAGAMENTO_FORMA', 1, '1,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (40, 'TBPERFIL', 1, '1,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (49, 'TBTRANSPORTADORA', 1, '1,4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (29, 'TBOCORRENCIA_WEB', 1, '2')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (30, 'TBOCORRENCIA_WEB_FREED', 1, '2')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (31, 'TBOCORRENCIA_WEB_MOTIVO', 1, '2')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (33, 'TBOCORRENCIA_WEB_STATUS', 1, '2')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (34, 'TBOCORRENCIA_WEB_TIPO', 1, '2')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (35, 'TBOCORRENCIA_WEB_USUARIOS', 1, '2')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (11, 'TBVISITA', 1, '3')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (48, 'TBTIPO_VISITA', 1, '3')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (5, 'TBGRADE', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (7, 'TBPEDIDO', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (17, 'TBCOR', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (23, 'TBMODELO', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (24, 'TBMODELO_BLOQUEIO_PERFIL', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (27, 'TBMODELO_PRECO', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (42, 'TBPERFIL_PEDIDO_USUARIOS', 1, '4')
                               MATCHING (ID);
UPDATE OR INSERT INTO TBMENU_APP_TABELA (ID, TABELA, STATUS, MENUS)
                                 VALUES (43, 'TBPRODUTO', 1, '4')
                               MATCHING (ID);

COMMIT WORK;