RE:Excel a Oracle 10g
Publicado por
Wilfredo (1 intervención) el 01/09/2010 22:01:52
Hola tienes 2 opcienes 1) puedes hacer un insert masivo mediante una planilla y ejecutarlo en la base de datos, 2)si necesitas hacerlo mediante codigo(programa fmb), puedes generar un proceso y asi seleccionar el Excel a cargar (definiendo el formato de las columnas) ej:
PROCEDURE ACTUALIZA IS
archivo CLIENT_text_io.file_type;
x_val VARCHAR2(3000);
CONT_LIN number := 0;
CONT_LIN_1 varchar2(1000);
dato varchar2(1000);
d_centro_costo varchar2(9);
d_proyecto varchar2(12);
conta_reg number;
d_presupuesto number;
d_ajuste_interno number;
d_ajuste_externo number;
d_monto_gasto number;
d_monto_ingreso number;
d_tipo varchar2(2);
v_pos_ini number := 0 ;
v_pos_fin number := 0 ;
n_ano number(4) := 0 ;
n_tipo varchar2(5);
n_rut number(9):=0;
n_fecha date;
nnn number :=0;
BEGIN
:sigue:='S';
archivo:= CLIENT_text_io.fopen(:ruta,'r');
CLIENT_text_io.get_line(archivo,x_val);
loop
CLIENT_text_io.get_line(archivo,x_val);
if x_val is null then
raise form_trigger_failure;
end if;
cont_lin := cont_lin + 1;
Begin
if length(cont_lin_1)<= 100 then
:log:= 'Procesando'||cont_lin||cont_lin_1||n_fecha_utm;
Else
cont_lin_1 := '.';
:log:= 'Procesando'||cont_lin_1||n_fecha_utm;
end if;
End;
synchronize;
v_pos_ini := 1;
v_pos_fin := instr( x_val, ';' ) - 1 ;
n_ano := to_number(substr( x_val,v_pos_ini, v_pos_fin ));
if n_ano is null then
message('No viene año'||cont_lin);
:sigue:='N';
raise form_trigger_failure;
end if;
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_tipo := substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 );
if n_tipo is null then
message('No existe tipo no puede ser nulo, Revise línea '||cont_lin);
:sigue:='N';
raise form_trigger_failure;
end if;
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_rut := to_number(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ));
if n_rut is null then
message('Proyecto no puede ser nulo '||cont_lin);
:sigue:='N';
raise form_trigger_failure;
end if;
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_carrera := to_number(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ));
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_monto := to_number(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ));
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_valor_cam:=to_number(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ));
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_monto_utm := to_number(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ));
--If n_monto_utm > 0 then
v_pos_ini := v_pos_fin + 2;
v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_folio := to_number(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ));
v_pos_ini := v_pos_fin + 2; v_pos_fin := instr( x_val,';',v_pos_ini ) - 1 ;
n_fecha_utm :=to_date(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini + 1 ),'dd/mm/yyyy');
n_fecha_utm :=to_date(substr( x_val,v_pos_ini, v_pos_fin - v_pos_ini ),'dd/mm/yyyy');
update fc_pagare
set fecha_utm = n_fecha_utm
where empresa = :global.cf
and ano = n_ano
and tipo = n_tipo
and rut = n_rut
and folio = n_folio;
Commit;
end loop;
EXCEPTION WHEN OTHERS THEN
message( 'error'||sqlerrm);
Message(' ',No_Acknowledge);
raise form_trigger_failure;
:sigue:='N';
END;
espero que te sirva