cursor

cursor:
  --定义存放游标数据和使用的变量
  f_id           monitor_info.id%TYPE;
  f_project_id   monitor_info.project_id%TYPE;
  f_check_id     monitor_info.check_id%TYPE;
  f_m_time       monitor_info.m_time%TYPE;
  f_level1       monitor_info.level1%TYPE;
  
--1.创建游标
declare 
  cursor cur_mf is   
  select mf.id,mf.project_id,mf.check_id,mf.m_time,mf.level1 from monitor_info mf where detection_flag=0;
--2.打开游标
open cur_mf; 
  loop
--3.将游标的当前行取出存放到变量中 
    fetch cur_mf into f_id,f_project_id,f_check_id,f_m_time,f_level1;
    exit when cur_mf%notfound;
      --打印结果:dbms_output.PUT_LINE(f_id||'->'||f_project_id||'->'||f_check_id||'->'||f_m_time||'->'||f_level1);
--自己的业务逻辑
  ......       
  end loop;
close cur_mf;  --4.关闭游标

猜你喜欢

转载自zhengfc323.iteye.com/blog/1506071