Clicky

Oracle - ORA-29282: invalid file ID, ORA-06512: at "SYS.UTL_FILE"

February 25, 2013

Problem:
Connecting to the database APPS_MANPOWER_PLUS_APPS.
ORA-29282: invalid file ID
ORA-06512: at “SYS.UTL_FILE”, line 878
ORA-06512: at “APPS_MANPOWER_PLUS.PKG_UPD_BULK”, line 421
ORA-06512: at line 6
-——————————————————————————-
Process exited.

, generated by:

(…) _
_  begin
    dbms_output.enable(null);
   
    dbms_output.put_line(RPAD('-',80,'-'));
    utl_file.put_line(lf, RPAD('-',80,'-'));
   
    l_logfile_name := ‘UPD_XXX’ || ‘_’ || to_char(sysdate, ‘YYYYMMDDHH24MISS’) || ‘.log’;
___
    **lf := utl_file.fopen(‘OPERATION_LOGS’, l_logfile_name, ‘W’);**__
   
    dbms_output.put_line(‘BEGIN: PKG_UPD_BULK.UPD____XXX_');
    utl_file.put_line(lf, ‘BEGIN: PKG_UPD_BULK.UPD____XXX_');_
_(…) _

Cause:
Write in the file before first open it. The correct code should be:

(…) _
_  begin
    dbms_output.enable(null);
   _
__    l_logfile_name := ‘UPD_XXX’ || ‘_’ || to_char(sysdate, ‘YYYYMMDDHH24MISS’) || ‘.log’;
    lf := utl_file.fopen(‘OPERATION_LOGS’, l_logfile_name, ‘W’);
_

_    dbms_output.put_line(RPAD('-',80,'-'));
    utl_file.put_line(lf, RPAD('-',80,'-'));
   
    dbms_output.put_line(‘BEGIN: PKG_UPD_BULK.UPD___XXX');
    utl_file.put_line(lf, ‘BEGIN: PKG_UPD_BULK.UPD__XXX');
_(…) _