
declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate
  	'CREATE TABLE CODIGO_BARRA_TRECHO (
	CODIGOBARRATRECHO_ID NUMBER(7, 0) NOT NULL ,
	ORIGEN_ID NUMBER(7,0),
    DESTINO_ID NUMBER(7,0),
    EMPRESA_ID NUMBER(7,0), 
	CODTERMINAL VARCHAR2(150),
    CODEMPRESA VARCHAR2(150),
    CODRUTA VARCHAR2(150),
	ACTIVO NUMBER(1,0) ,
	FECMODIF DATE,
	USUARIO_ID NUMBER(7,0),
	PRIMARY KEY (CODIGOBARRATRECHO_ID)
	)';
 exception when object_exists then null;
end;
/

declare
    object_exists exception;
    pragma exception_init (object_exists , -00955);
begin
  execute immediate
  	'CREATE SEQUENCE  CODIGOBARRATRECHO_SEQ  MINVALUE 1 MAXVALUE 9999999 INCREMENT BY 1 START WITH 1 NOCACHE ORDER CYCLE';	
  exception when object_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 > CODIGO BARRA TRECHO'',''COM.RJCONSULTORES.ADMINISTRACION.GUI.CATALOGOS.CODIGOBARRATRECHO'',''1'',SYSDATE,''1'')';
 
  exception 
    when dup_val_on_index  then null;
    when except_02291  then null;
end;
/