CREATE TABLE TBACESSO_IP (
    ID INTEGER,
    IP VARCHAR(100),
    STATUS INTEGER,
    DESCRICAO VARCHAR(100));

CREATE SEQUENCE GTBACESSO_IP;

SET TERM ^ ;

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

SET TERM ; ^

ALTER TABLE TBACESSO_IP
    ADD BLOQUEAR_HORA INTEGER,
    ADD BLOQUEAR INTEGER DEFAULT 0,
    ADD HORA_INICIO VARCHAR(10) DEFAULT '00:00',
    ADD HORA_FIM VARCHAR(10) DEFAULT '23:59',
    ADD SEG INTEGER DEFAULT 0,
    ADD TER INTEGER DEFAULT 0,
    ADD QUA INTEGER DEFAULT 0,
    ADD QUI INTEGER DEFAULT 0,
    ADD SEX INTEGER DEFAULT 0,
    ADD SAB INTEGER DEFAULT 0,
    ADD DOM INTEGER DEFAULT 0;

UPDATE OR INSERT INTO TBACESSO_IP (ID, IP, STATUS, DESCRICAO, BLOQUEAR_HORA, BLOQUEAR, HORA_INICIO, HORA_FIM, SEG, TER, QUA, QUI, SEX, SAB, DOM)
   VALUES (1, '*', 1, 'PADRÃO', 0, 0, '00:00:00', '23:59:59', 1, 1, 1, 1, 1, 1, 1)
 MATCHING (ID);
						 
						 