-1

I have a plsql procedure that runs successfully . When i call this procedure into another procedure in a different package, it error's out with invalid file id .

 Proc test1(debug varchar2 default 0) as
     dt    date; 
    cursor 1 
select sysdate as dt from dual;
   
    Begin
     IF month(dt) < Dec THEN
        update table1
         set term_date= sysdate +10
        where table1_year='2023'
      END IF; 
    End;



  Procedure test2(value varchar2) as 

Begin
     report_file:=utl_file.fopen(lC_report_dir_obj_out,lC_report_fname,'w');
    If value='Y' THEN
    BEGIN
      Proc test1(1);
    dbms_output.put_line('Run test1 success');
lv_msg :=success;
    Exception
      WHEN OTHERS THEN
      dbms_output.put_line('Run test1 success');
lv_msg :=sqlerrm; 
    END;
     utl_file.put_line(report_file,lv_msg,autoflush=>TRUE);
    End if ;
    
    End test2;

Error : ORA-29282: invalid file ID ORA-06512: at "SYS.UTL_FILE", line 166 ORA-06512: at "SYS.UTL_FILE", line 866

It has no issues writing to the file if not for the procedure call . The procedure has numerous loops and go by each row from the cursor .

arsha
  • 67
  • 6
  • show complete error stack and post a [mcve] please – OldProgrammer Jun 16 '23 at 15:49
  • I tried to reproduce the code as much as i can – arsha Jun 16 '23 at 16:23
  • You have all kinds of variables that aren't defined, we have no idea what they are. Further your error backtrace is lacking the line number from your procedure so we don't know if the error was on the fopen or the put_line. We also don't know what directory object this is, whether you have permissions, whether the path exists on the OS or not... that's why you're being asked for more details. – Paul W Jun 16 '23 at 16:56
  • Error is at line 15, If i comment out the procedure call , it works fine . – arsha Jun 16 '23 at 17:10
  • 1
    You need to run interactive debug session and examine all the variables along the execution flow. It would be **much** more productive than debugging of pseudo code at Q&A site – astentx Jun 16 '23 at 17:19

1 Answers1

0

The the procedure test1 had a fclose all , that closed all the files including the file opened by procedure test2 . I made the change and the procedure finished successfully.

arsha
  • 67
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 25 '23 at 01:37