1. 程式人生 > >簡單動態遊標寫法

簡單動態遊標寫法


-- 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;