0

I have to read a big file line by line, usually more than 400 kb, change some values and write the file changed in another file.

My problema now is that I'm having a ora-06502 in the fopen .... the code is like this

CREATE OR REPLACE PROCEDURE pfichero (pnomficheroorigen in VARCHAR2, 
    pnomficherodestino in varchar2) AS
  
    vcdclasnm varchar2(2) := '01';
    vhabilitacion_destino varchar2(3) := 'PRU';
    v_filehandleorigen UTL_FILE.FILE_TYPE;
    v_filehandledestino UTL_FILE.FILE_TYPE;
    v_nomficheroorigen VARCHAR2(50) := pnomficheroorigen;
    v_nomficherodestino VARCHAR2(50) := pnomficherodestino;
    v_linea varchar2(32767);
    vlineadestino varchar2(32767);
BEGIN
    dbms_output.put_line ('traza 0: '||v_nomficheroorigen);
    v_filehandleorigen  := UTL_FILE.FOPEN('DIR_DESA',v_nomficheroorigen,'R',32767);
    dbms_output.put_line ('traza 1');
    v_filehandledestino := UTL_FILE.FOPEN('DIR_DESA',v_nomficherodestino,'W',32767);

The error ocurrs on the line "v_filehandleorigen := UTL_FILE.FOPEN('DIR_DESA',v_nomficheroorigen,'R',32767);".

Can anyone can help me?

Thanks a lot

William Robertson
  • 15,273
  • 4
  • 38
  • 44
Dembora
  • 3
  • 2
  • What is the whole error message? – William Robertson May 18 '21 at 06:49
  • Procedimiento PL/SQL terminado correctamente. INICIO traza 0: Carga2b.dat ORA-06502: PL/SQL: error : error de conversión de carácter a número numérico o de valor – Dembora May 18 '21 at 07:08
  • At the end it was the error was invalid operation. Appeared when I uncommented the exception block. And I don't understand it, because one of the exceptions was WHEN UTL_FILE.INVALID_OPERATION THEN Rollback; verror: = sqlerrm; dbms_output.put_line (verror); utl_file.fclose_all; Thanks. – Dembora May 18 '21 at 07:36
  • Sample data and complete code would help a lot. – William Robertson May 18 '21 at 19:12

0 Answers0