DO $$
BEGIN
  CREATE TABLE DET_ABASTO_BOLETO_HIST (
       DETABASTOBOLETOHIST_ID NUMERIC(15) NOT NULL,
       DETABASTOBOLETOENV_ID INTEGER NULL,
       DETABASTOBOLETOREC_ID INTEGER NULL,
       FECMODIF             TIME without TIME zone,
       ACTIVO               SMALLINT,
       USUARIO_ID           INTEGER,
       PRIMARY KEY (DETABASTOBOLETOHIST_ID), 
       FOREIGN KEY (USUARIO_ID) REFERENCES USUARIO, 
       FOREIGN KEY (DETABASTOBOLETOREC_ID) REFERENCES DET_ABASTO_BOLETO, 
       FOREIGN KEY (DETABASTOBOLETOENV_ID) REFERENCES DET_ABASTO_BOLETO
  );	
	
  CREATE SEQUENCE DET_ABASTO_BOLETO_HIST_SEQ INCREMENT BY 1 START WITH 1 NO CYCLE;
  
  EXCEPTION 
    WHEN duplicate_table THEN NULL;
    WHEN duplicate_object THEN NULL;
    WHEN duplicate_column THEN NULL;
END
$$;
