CREATE TABLE TBSETOR_RFID (
    ID INTEGER NOT NULL,
    CODIGO INTEGER NOT NULL,
    DESCRICAO VARCHAR(200),
    STATUS INTEGER,
    DATAHORA TIMESTAMP DEFAULT LOCALTIMESTAMP NOT NULL);

ALTER TABLE TBSETOR_RFID
ADD CONSTRAINT PK_TBSETOR_RFID
PRIMARY KEY (ID);

COMMENT ON COLUMN TBSETOR_RFID.STATUS IS
'STATUS DO REGISTRO
0 - INATIVO;
1 - ATIVO;';

CREATE SEQUENCE GTBSETOR_RFID;

SET TERM ^ ;

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

SET TERM ; ^

CREATE INDEX ITBSETOR_RFID_01
ON TBSETOR_RFID (CODIGO);

CREATE INDEX ITBSETOR_RFID_02
ON TBSETOR_RFID (STATUS);

