declare
     type s_stu is ref cursor
     return student%rowtype;
     c_stu s_stu;
     stu student%rowtype;
     begin
     open c_stu for
     select * from student;
     fetch c_stu into stu;
     exit when  stu%notfound;
      dbms_output.put_line(stu.sid ||'   '||stu.CODE||'    '|| stu.BIRTHDAY ||'     '||stu. SEX|| '    '||stu.ADDRESS);
      end loop;
     close c_stu;
     end;
提示说:
ORA-06550: 第 13 行, 第 6 列: 
PLS-00103: 出现符号 "CLOSE"
初学者
不知道错在哪里,帮助下谢谢!

解决方案 »

  1.   

    declare
        v_ename emp.ename%type;
        v_sal emp.sal%type;
        cursor c_cursor is 
            select ename ,sal from emp where deptno = 20;begin
        open c_cursor; -- 打开游标
        fetch c_cursor into v_ename,v_sal;   --获取数据
        while c_cursor%found loop -- 当游标里有数据就执行下面的打印操作
           dbms_output.put_line(v_ename || ' sal is : '||v_sal);
        fetch c_cursor into v_ename , v_sal;
       end loop;
       close c_cursor;
      
    end;
      

  2.   


    --没测试过,根据你的要求改编的:
    declare
           cursor cv_stu_cursor is
             select sid,code,birthday,sex,address
             from student;
    begin
         for v_stu in cv_stu_cursor loop
         dbms_output.put_line(
           'stu_id='||v_stu.sid||',stu_code='||v_stu.code||
           ',stu_birthday='||v_stu.birthday||',stu_sex='||v_stu.sex||
           ',stu_addr='||v_stu.address);
         end loop;
    end;
      

  3.   


    declare
      type s_stu is ref cursor return student%rowtype;
      c_stu s_stu;
      stu   student%rowtype;
    begin
      open c_stu for
        select * from student;
      loop    --加个loop
        fetch c_stu
          into stu;
        exit when c_stu%notfound;   --stu改成c_stu
        dbms_output.put_line(stu.sid || ' ' || stu.CODE || ' ' || stu.BIRTHDAY || ' ' || stu.
                             SEX || ' ' || stu.ADDRESS);
      end loop;
      close c_stu;
    end;
      

  4.   


    declare
      type s_stu is ref cursor return student%rowtype;
      c_stu s_stu;
      stu   student%rowtype;
    begin
      open c_stu for
        select * from student;
      loop    --加个loop
        fetch c_stu
          into stu;
        exit when c_stu%notfound;   --stu改成c_stu
        dbms_output.put_line(stu.sid || ' ' || stu.CODE || ' ' || stu.BIRTHDAY || ' ' || stu.
                             SEX || ' ' || stu.ADDRESS);
      end loop;
      close c_stu;
    end;