You can register progress in an offline transaction .
i.e. write the rows processed into the log table in a separate transaction (with its own commits) via AT, something like:
CREATE OR REPLACE PROCEDURE log_progress ( p_id IN NUMBER, p_data IN VARCHAR2 ) AS PRAGMA AUTONOMOUS_TRANSACTION; BEGIN INSERT INTO log_table ( id, logging_data ) VALUES ( p_id, p_data );
If the process is canceled, you can request the data registered in AT and find out how many rows were processed, since the insertion entries in the log table will not be canceled by your "main" transaction.
Another method would be to write to the log file using the UTL_FILE package, and then read the contents of the file if the transaction is canceled.
By the way, you can put (pretty much) any code you want into the exception section, and it will be executed if that exception is raised. There must be another reason why your code either fails or is rolled back by the transaction that raised the exception.
http://www.exforsys.com/tutorials/oracle-11g/oracle-11g-exception-handling.html
Hope this helps ...
Ollie source share