定义表S2,表结构同student表相同.编写存储过程,在过程中利用游标将student表中系别为'CS'的记录插入到表S2中create or replace procedure s_test as  
CURSOR c_job IS select * from student where sdept='CS';
c_row c_job%rowtype;
begin  
  open c_job;  
LOOP  
  FETCH c_job INTO c_row;  
  exit when c_job%notfound;
  dbms_output.put_line(c_row.sno||'-'||c_row.sname||'-'||c_row.sdept);
  INSERT INTO S2(sno,sname,sdept) VALUES(c_row.sno,c_row.sname,c_row.sdept);  
END LOOP;  
  END c_job;
end;
 答案错在哪里了?求改正 
 
 

解决方案 »

  1.   

    [create or replace procedure s_test
    as   
    CURSOR c_job IS select * from student where sdept='CS';
    c_row student%rowtype;
    begin   
      open c_job;   
    LOOP   
      FETCH c_job INTO c_row;   
      exit when c_job%notfound;
      dbms_output.put_line(c_row.sno||'-'||c_row.sname||'-'||c_row.sdept);
      INSERT INTO S2(sno,sname,sdept) VALUES(c_row.sno,c_row.sname,c_row.sdept);   
    END LOOP;   
      close c_job;
    end;
    ][/code]
      

  2.   

    select出来的数据是多条的  fetch只能取出一条  
      

  3.   

    Compilation errors for PROCEDURE SYSTEM.S_TESTError: PLS-00113: END 标识符 'C_JOB' 必须同 'S_TEST' 匹配 (在第 1 行, 第 11 列)
    Line: 12
    Text: END c_job;Error: PLS-00103: 出现符号 "END"
    Line: 13
    Text: end;
      

  4.   

    关闭游标
    close c_job;