Using DBMS_OUTPUT means that SQL * Plus will not display anything until the entire PL / SQL block is complete, and then will display all the data in the buffer. Therefore, this is not an appropriate way to ensure permanent status.
Oracle, on the other hand, provides the DBMS_APPLICATION_INFO package, which is specifically designed to help you keep track of current code. For example, you can do something like
CREATE PROCEDURE process_structures AS <<other variable declarations>> rindex BINARY_INTEGER; slno BINARY_INTEGER; totalwork NUMBER := y; -- Total number of structures worksofar NUMBER := 0; -- Number of structures processed BEGIN rindex := dbms_application_info.set_session_longops_nohint; FOR i IN (<<select structures to process>>) LOOP worksofar := worksofar + 1; dbms_application_info.set_session_longops( rindex => rindex, slno => slno, op_name => 'Processing of Molecular Structures', sofar => worksofar , totalwork => totalwork, target_desc => 'Some description', units => 'structures'); <<process your structure with your existing code>> END LOOP; END;
In a separate SQL * Plus session, you can track progress by requesting a view of V$SESSION_LONGOPS
SELECT opname, target_desc, sofar, totalwork, units, elapsed_seconds, time_remaining FROM v$session_longops WHERE opname = 'Processing of Molecular Structures';
source share