csbin

1、创建存储过程
create or replace procedure work_process is
  rindex    binary_integer;
  slno      binary_integer;
  totalwork number;
  sofar     number;
  obj       binary_integer;
begin
  rindex    := dbms_application_info.set_session_longops_nohint;
  sofar     := 0;
  totalwork := 10;
  while sofar < 10 loop
 
    -- dbms_lock.sleep(5); 休眠5秒
    sofar := sofar + 1;
    dbms_application_info.set_session_longops(rindex,
                                              slno,
                                              'Operation X',
                                              obj,
                                              0,
                                              sofar,
                                              totalwork,
                                              'table',
                                              'tables');
 
  end loop;
end work_process;
/
注意:默认情况下当前用户没有dbms_lock包的运行权限,需要授权。grant execute on dbms_lock to aptstest;

2、查询运行进度
select * from v$session_longops where opname = 'Operation X';

你可能感兴趣的:(职场,休闲)