CREATE TABLE TBPDV_NF_CCE (
    ID INTEGER NOT NULL,
    PDV_CFE_ID INTEGER,
    SEQUENCIAL INTEGER,
    ARQUIVO BLOB SUB_TYPE 0 SEGMENT SIZE 80,
    PROTOCOLO VARCHAR(50),
    DATAHORA_INICIO TIMESTAMP DEFAULT 'NOW',
    DATAHORA_FIM TIMESTAMP DEFAULT 'NOW');

ALTER TABLE TBPDV_NF_CCE
ADD CONSTRAINT PK_TBPDV_NF_CCE
PRIMARY KEY (ID);

CREATE SEQUENCE GTBPDV_NF_CCE;

SET TERM ^ ;

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

SET TERM ; ^


CREATE INDEX ITBPDV_NF_CCE_01
ON TBPDV_NF_CCE (PDV_CFE_ID);

CREATE INDEX ITBPDV_NF_CCE_02
ON TBPDV_NF_CCE (SEQUENCIAL);

