declare
       type xn_dept_cursor is ref cursor;
       test_cursor xn_dept_cursor;

declare
       cursor c1 is select ......这两种有什么区别?安全性上执行速度还是就是写法不一样?

解决方案 »

  1.   

    前者是引用游标,一次定义,多次使用。结果集不定。
    后者是显式游标,结果集确定。
    速度要看其具体SQL语句,并没有绝对的区别。
      

  2.   

    就是说第一种可以
    open test_cursor for select......
    以后在别的地方再
    open test_cursor for select......
    对吧?最后在结尾关闭游标?
      

  3.   

    前者不需要你手工关闭,它会自动关闭。
    前者常用于做报表,返回结果集。后者常用于loop,循环处理。需要手动关闭。