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

ALTER TABLE TBPSP
ADD CONSTRAINT PK_TBPSP
PRIMARY KEY (ID);

COMMENT ON COLUMN TBPSP.CODIGO IS
'CODIGO DO BANCO';

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

CREATE SEQUENCE GTBPSP;

SET TERM ^ ;

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

SET TERM ; ^

CREATE INDEX ITBPSP_01
ON TBPSP (CODIGO);


CREATE INDEX ITBPSP_02
ON TBPSP (STATUS);

