简单动态游标写法


-- Created on 2018/5/28 
declare 
  -- Local variables here
  V_SQL        VARCHAR2(1000); 
  --i integer;
   rec_kc22    kc22%rowtype;
   TYPE ref_cursor_type IS REF CURSOR; --定义一个动态游标     
    usrs ref_cursor_type;
begin
  -- Test statements here
  v_sql := 'select * from kc22 where id = 355896010';
    open usrs for v_sql;
        loop
          fetch usrs
            into rec_kc22;
          exit when usrs%notfound;

        dbms_output.put_line(rec_kc22.id);      

        end loop;
        close usrs;
end;

猜你喜欢

转载自blog.csdn.net/qq_28198893/article/details/80486168