根据OEM会话等待数的阀值插入到记录表中(pl/sql);

declare
v_wait_class u_sys_info.wait_class%type;
v_qty        u_sys_info.qty%type;
cursor c_info is
select nvl(wait_class,'cpu'),qty
from u_sys_info;
begin
open c_info;
loop
          fetch c_info into v_wait_class,v_qty;
          exit when c_info%notfound;
case
     when v_wait_class='cpu' and v_qty>=40 then
          insert into u_sys_info2  select * from u_sys_info where wait_class=v_wait_class;
          commit;
     when v_wait_class='User I/O' and v_qty>=53 then
          insert into u_sys_info2  select * from u_sys_info where wait_class=v_wait_class;
          commit;
     when v_wait_class<>'cpu' and v_wait_class<>'User I/O' and v_qty>1.7 then
          insert into u_sys_info2  select * from u_sys_info
          where wait_class=(select wait_class from u_sys_info
                            where qty=(select max(qty) from u_sys_info
                                   where wait_class<>'cpu'
                                   and wait_class<>'User I/O'
                                   and qty>1.7));
          commit;
     else
          dbms_output.put_line('not exists');
end case;
end loop;
close c_info;
end;
/


你可能感兴趣的:(c,user,Class,insert)