I developed a PL/SQL stored procedure which returns a sys_refcursor
create or replace procedure updateProgress( ref_out out sys_refcursor
, v_context in number)
is
begin
open ref_out
for select serial# serialnumber
, time_remaining remainingtime
, elapsed_seconds elapsedtime
, (100 * sofar) / totalwork accomplishedpercentage
from v$session_longops
where target = 9
and target_desc = 'inserting nonsense'
and context = v_context;
end updateProgress;
I’m going to execute this procedure within a single session a number of times. After the first call, does each subsequent call execute the query again or is the result of the first query cached to be reused for subsequent calls?
It will not be cached; the query will be executed for each call.
Be careful: querying the
v$session_longopsis not a very reliable way to monitor the progress of execution. The data returned is not always full (e.g. not all SQL statements might be included) and I definitely would not rely on thetime_remainingvalue; to me it often seemed to be a wild guess rather than a good estimation…