-- CREATE TABLE/CREATE SEQUENCE
declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE TABLE RUTA_ICMS_EXCEPCION (
       RUTAICMSEXCEPCION_ID NUMBER(7) NOT NULL,
       ORIGEN_ID            NUMBER(7) NULL,
       DESTINO_ID           NUMBER(7) NULL,
       RUTA_ID              NUMBER(7) NULL,
       INDTRIBTARIFA        NUMBER(1) NULL,
       INDTRIBTAXAEMBARQUE  NUMBER(1) NULL,
       INDTRIBPEDAGIO       NUMBER(1) NULL,
       ACTIVO               NUMBER(1) NULL,
       FECMODIF             DATE NULL,
       USUARIO_ID           NUMBER(7) NULL,
       PRIMARY KEY (RUTAICMSEXCEPCION_ID), 
       FOREIGN KEY (RUTA_ID) REFERENCES RUTA, 
       FOREIGN KEY (DESTINO_ID) REFERENCES PARADA, 
       FOREIGN KEY (ORIGEN_ID) REFERENCES PARADA
	)';
  exception when object_exists then null;
end;
/
declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate 'CREATE SEQUENCE RUTA_ICMS_EXCEPCION_SEQ INCREMENT BY 1 START WITH 1 NOCYCLE';
  exception when object_exists then null;
end;