declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate
  	'CREATE SEQUENCE  ASISTVIAJE_EMPRESA_SEQ  MINVALUE 1 MAXVALUE 9999999 INCREMENT BY 1 START WITH 1 NOCACHE ORDER CYCLE';	
  exception when object_exists then null;
end;
/
declare
    table_exists exception;
    pragma exception_init (table_exists , -00955);
begin
  execute immediate
	'CREATE TABLE ASISTVIAJE_EMPRESA (
	ASISTVIAJEEMPRESA_ID NUMBER(7,0) NOT NULL ENABLE, 
	EMPRESA_ID NUMBER(7,0), 
	TARIFA NUMBER(10,2), 
	ACTIVO NUMBER(1,0), 
	FECMODIF DATE, 
	USUARIO_ID NUMBER(7,0), 
	 PRIMARY KEY (ASISTVIAJEEMPRESA_ID),
	 FOREIGN KEY (EMPRESA_ID)
	 REFERENCES EMPRESA (EMPRESA_ID) ENABLE
	) ';
	
  exception when table_exists then null;
end;
/
declare
    column_exists exception;
    pragma exception_init (column_exists , -01430);
begin
    execute immediate 'ALTER TABLE PTOVTA_SEGURO ADD INDVENDASISTVIAJE NUMBER (1,0)';
    exception when column_exists then null;
end;
/
declare
    column_exists exception;
    pragma exception_init (column_exists , -01430);
begin
    execute immediate 'ALTER TABLE PTOVTA_SEGURO ADD INDESTANASISTVIAJE NUMBER (1,0)';
    exception when column_exists then null;
end;
/
declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate
  	'CREATE TABLE IMPRESION_LAYOUT_CONFIG (
	IMPRESIONLAYOUTCONFIG_ID NUMBER(7, 0) NOT NULL ,
	DESCRICAO VARCHAR2(100 BYTE), 
	TEXTO CLOB ,
	LINGUAGEM NUMBER(5,0),
	ACTIVO NUMBER(1,0) ,
	FECMODIF DATE,
	USUARIO_ID NUMBER(7,0)
	)';
 exception when object_exists then null;
end;
/
declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate
	'CREATE SEQUENCE IMPRESION_LAYOUT_CONFIG_SEQ MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER NOCYCLE';
 exception when object_exists then null;
end;
/


declare
    column_exists exception;
    pragma exception_init (column_exists , -01430);
begin
    execute immediate 'ALTER TABLE TIPO_EVENTO_EXTRA ADD (IMPRESIONLAYOUTCONFIG_ID NUMBER(7) )';
    exception when column_exists then null;
end;
/



declare
  dup_val_on_index  exception;
  except_02291  exception;

  pragma exception_init (dup_val_on_index  , -00001);
  pragma exception_init (except_02291  , -02291);
begin
  execute immediate 
  'insert into FUNCION_SISTEMA (FUNCIONSISTEMA_ID,SISTEMA_ID,NOMBFUNCION,DESCRUTA,ACTIVO,FECMODIF,USUARIO_ID)
   values
   (FUNCION_SISTEMA_SEQ.NEXTVAL,''1'',''ADM > CATALOGOS > LAYOUT COMPROVANTE'',''COM.RJCONSULTORES.ADMINISTRACION.GUI.CATALOGOS.IMPRESIONLAYOUTCONFIG'',''1'',SYSDATE,''1'')';
 
  exception 
    when dup_val_on_index  then null;
    when except_02291  then null;
end;
/
declare
  dup_val_on_index  exception;
  except_02291  exception;

  pragma exception_init (dup_val_on_index  , -00001);
  pragma exception_init (except_02291  , -02291);
begin
  execute immediate 
  'insert into FUNCION_SISTEMA (FUNCIONSISTEMA_ID,SISTEMA_ID,NOMBFUNCION,DESCRUTA,ACTIVO,FECMODIF,USUARIO_ID)
   values
   (FUNCION_SISTEMA_SEQ.NEXTVAL,''1'',''ADM > ADM DE PRECO > ASSISTENTE VIAJE'',''COM.RJCONSULTORES.ADMINISTRACION.GUI.TARIFAS.MENU.ASISTENCIADEVIAGEMEMPRESA'',''1'',SYSDATE,''1'')';
 
  exception 
    when dup_val_on_index  then null;
    when except_02291  then null;
end;
