declare
  object_exists exception;
  pragma exception_init (object_exists , -00955);
    begin
    execute immediate '
	    CREATE TABLE ESQUEMA_CORRIDA_INFO(
	      ESQUEMACORRIDAINFO_ID NUMBER(7,0) NOT NULL,
	      ESQUEMACORRIDA_ID NUMBER(7,0) NOT NULL,	  
          ORIGEN_ID NUMBER(7,0),
 		  DESTINO_ID NUMBER(7,0),
		  INFOCORRIDA VARCHAR2(40 BYTE),
	      ACTIVO NUMBER(1,0),
	      FECMODIF DATE,
	      USUARIO_ID NUMBER(7,0),
	      CONSTRAINT PK_ESQ_CORR_INFO PRIMARY KEY(ESQUEMACORRIDAINFO_ID),
	      CONSTRAINT FK_ESQ_CORR_INFO FOREIGN KEY (ESQUEMACORRIDA_ID) REFERENCES ESQUEMA_CORRIDA(ESQUEMACORRIDA_ID)
	  	)';
    exception when object_exists then null;
end;
/

declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
    execute immediate 'CREATE SEQUENCE "ESQUEMA_CORRIDA_INFO_SEQ" INCREMENT BY 1 START WITH 1 NOCACHE ORDER NOCYCLE';
    exception when object_exists then null;
end;

/

declare
  object_exists exception;
  pragma exception_init (object_exists , -00955);
    begin
    execute immediate '
	    CREATE TABLE CORRIDA_INFO (
	      CORRIDAINFO_ID NUMBER(7,0) NOT NULL,
	      CORRIDA_ID NUMBER(7,0) NOT NULL,
	  	 FECCORRIDA DATE,	  
          ORIGEN_ID NUMBER(7,0),
 		  DESTINO_ID NUMBER(7,0),
		 INFOCORRIDA VARCHAR2(40 BYTE), 
	      ACTIVO NUMBER(1,0),
	      FECMODIF DATE,
	      USUARIO_ID NUMBER(7,0),
	      CONSTRAINT PK_CORR_INFO PRIMARY KEY(CORRIDAINFO_ID),
	      CONSTRAINT FK_CORR_INFO FOREIGN KEY (CORRIDA_ID, FECCORRIDA) REFERENCES CORRIDA(CORRIDA_ID, FECCORRIDA)
	  	)';
    exception when object_exists then null;
end;
/


declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
    execute immediate 'CREATE SEQUENCE "CORRIDA_INFO_SEQ" INCREMENT BY 1 START WITH 1 NOCACHE ORDER NOCYCLE';
    exception when object_exists then null;
end;

/

declare
    column_exists exception;
    pragma exception_init (column_exists , -01430);
begin
    execute immediate 'ALTER TABLE ESQUEMA_CORRIDA_INFO ADD ( INFOCORRIDA VARCHAR2(40 BYTE))';
    exception when column_exists then null;
end;
/

declare
    column_exists exception;
    pragma exception_init (column_exists , -01430);
begin
    execute immediate 'ALTER TABLE CORRIDA_INFO ADD ( INFOCORRIDA VARCHAR2(40 BYTE))';
    exception when column_exists then null;
end;
/
