什么叫普通游标?
ref是可以定义为游标变量:
type t1 is ref cursor
v1 t1;静态游标:
cursor t1 is
select * from table_name;静态游标相当于遍历记录集,而游标变量定义一个记录集,给予调用

解决方案 »

  1.   

    是否有实例,以scott用户的dept表为例
      

  2.   

    游标变量:
    create PROCEDURE get (p_id NUMBER)
    IS
    type t1 is ref cursor;
    v1 t1;
    BEGIN
          IF p_id = 0 THEN
             OPEN v1 FOR
                SELECT ID, NAME, sex, address, postcode, birthday
                  FROM student;
          ELSE
             sqlstr :=
                'select id,name,sex,address,postcode,birthday
               from student where id=:w_id';
             OPEN v1 FOR sqlstr USING p_id;
          END IF;
    END get;静态游标:
    declare
    cursor t1 is
    SELECT ID, NAME, sex, address, postcode, birthday FROM student;
    begin
    for v1 in t1 loop
    dbms_out.output_line(v1.ID||v1.NAME||v1.sex||v1.address||v1.postcode||v1.v_birthday);
    end loop;
    end;
    /