我在PL/SQL里用如下代码建立游标,
declare cursor cu_student_name is
select student_name
from students;然后报如下错误,不知道为什么
ORA-06550: 第 4 行, 第 0 列: 
PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
 begin function
   package pragma procedure subtype type use <an identifier>
   <a double-quoted delimited-identifier> form current cursor

解决方案 »

  1.   

    没有完整的代码吗?
    下面是一个例子
    create or replace procedure system.sp_UpdateCartItem as
      
      cursor cur_cartitem is
        select *
          from scm_order_cartitem t0
         where t0.states = 0
           and (t0.buytime + (interval '5' minute)) > sysdate;
    begin
      for rec in cur_cartitem loop
        if (rec.tempalteid = 1) then
          --申请号码
          update scm_order_cartitem t0
             set t0.states = 2
           where t0.cartitemid = rec.cartitemid
             and t0.states = 0;
          delete from scm_order_num t1 where t1.cartitemid = rec.cartitemid;    else
          --申请物品
          update scm_order_cartitem t0
             set t0.states = 2
           where t0.cartitemid = rec.cartitemid
             and t0.states = 0;    end if;
      end loop;
    end sp_UpdateCartItem;
      

  2.   

    游标是使用应该是这样的:
    declare C1 cursor for
      select sysdate 
      from dual;
    //定义游标C1open C1;
    //打开游标C1fetch C1 into :ls_date; 
       处理语句
    //使用游标C1close C1;
    //关闭游标C1
      

  3.   

    declare cursor cu_student_name is
    select student_name from students;全部代码就是这个,然后在declare的d的下面有一个红色波浪线,报如下错误
    ORA-06550: 第 3 行, 第 0 列:  
    PLS-00103: 出现符号 "end-of-file"在需要下列之一时:
      begin function
       package pragma procedure subtype type use <an identifier>
       <a double-quoted delimited-identifier> form current cursor
      

  4.   

    定义游标的代码放在begin...end里面了?