Using DBMS_OUTPUT means that SQL*Plus will display nothing until the entire PL/SQL block is complete and will then display all the data currently in the buffer. It is not, therefore, an appropriate way to provide an ongoing status.
On the other hand, Oracle does provide a package DBMS_APPLICATION_INFO that is specifically designed to help you monitor your running code. For example, you could 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;
From a separate SQL*Plus session, you can then monitory progress by querying the V$SESSION_LONGOPS view
SELECT opname, target_desc, sofar, totalwork, units, elapsed_seconds, time_remaining FROM v$session_longops WHERE opname = 'Processing of Molecular Structures';