Toad World® Forums

DBMS Output not working after ORA-04068

DBMS Output still looks enabled, but it does not work after
ORA-04068: existing state of packages has been discarded.

Is there a way to re-enable DBMS Output automatically or at least display it as disabled?

Steps to reproduce

Session 1

  • Enable DBMS Output

    CREATE PACKAGE package_with_state AS
      global_variable NUMBER;
    END package_with_state;
    
  • EXEC package_with_state.global_variable := 1;
    

Session 2

  • CREATE OR REPLACE PACKAGE package_with_state AS
      global_variable NUMBER := 2;
    END package_with_state;
    

Session 1

  • EXEC dbms_output.put_line( package_with_state.global_variable );
    
    • Exception as expected:

      ORA-04068: existing state of packages has been discarded

  • EXEC dbms_output.put_line( package_with_state.global_variable );
    
    • :exclamation: DBMS Output still displayed as enabled, but nothing printed
  • Disable and enable DBMS Output

  • EXEC dbms_output.put_line( package_with_state.global_variable );
    
    • Works as again