Oracle遊標類型作為傳入傳出參數

來源:互聯網
上載者:User

Oracle遊標類型作為傳入傳出參數:

--遊標類型傳入參數 
DECLARE 
  /*CURSOR cur_ttt IS
  SELECT 1 a FROM dual;*/
 
  TYPE typ_cur IS REF CURSOR; 
  val_cur typ_cur;
 
  PROCEDURE temp_sp1(x_cur OUT typ_cur) IS
  BEGIN
      OPEN x_cur FOR SELECT 1 a FROM dual UNION ALL SELECT 2 FROM dual;
  END;
 
  PROCEDURE temp_sp2(p_cur IN typ_cur) IS
    i NUMBER;
  BEGIN
    LOOP
      FETCH p_cur INTO i;
      EXIT WHEN p_cur%NOTFOUND;
      dbms_output.put_line(i);
    END LOOP;
    CLOSE p_cur;
  END;
BEGIN
  temp_sp1(val_cur);
  temp_sp2(val_cur);
 
  OPEN val_cur FOR SELECT 3 a FROM dual UNION ALL SELECT 4 FROM dual;
  temp_sp2(val_cur);
END;

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.