CREATE TABLE TBPDV_CFE_LOTE (
    ID INTEGER NOT NULL,
    PDV_CFE_ID INTEGER,
    LOTE INTEGER,
    RECIBO VARCHAR(20),
    XML VARCHAR(2),
    PROTOCOLO VARCHAR(20),
    PROTOCOLO_CANCELAMENTO VARCHAR(20),
    OBSERVACAO VARCHAR(255),
    DATAHORA TIMESTAMP);
	
ALTER TABLE TBPDV_CFE_LOTE
ADD CONSTRAINT PK_TBPDV_CFE_LOTE
PRIMARY KEY (ID);

CREATE SEQUENCE GTBPDV_CFE_LOTE;

create trigger tbpdv_cfe_lote_b01i for tbpdv_cfe_lote
active before insert position 0
as
begin
  if (new.id is null) then
    new.id = gen_id(gtbpdv_cfe_lote,1);
end;