在程序中使用游标

时间:2017-08-08 20:51:26

标签: plsql

为什么我收到以下错误,请告诉我代码中的错误。 ORA-06511:PL / SQL:游标已经打开

代码:

create or replace procedure student_info IS  
c_id student_details.student_id%type  ;      
c_name student_details.student_name%type;  
c_status student_details.student_status%type;

cursor stu_c1 IS  
select *  from student_details  
where student_status='Absent';  
begin  
open stu_c1;  
Fetch stu_c1 into c_id,c_name,c_status ;  
for rec in stu_c1 loop  
insert into student_data values (c_status,c_id,c_name);  
commit;  
end loop;   
CLOSE stu_c1;    
end;

1 个答案:

答案 0 :(得分:1)

如果您使用import React, {Component} from 'react'; import 'react-big-calendar/lib/css/react-big-calendar.css' import BigCalendar from 'react-big-calendar'; import moment from 'moment'; import 'moment/locale/pl'; class NewCalendar extends Component { constructor(props, context) { super(props, context); BigCalendar.momentLocalizer(moment); } render() { return ( <div {...this.props}> <BigCalendar messages={{next: "Następny", previous: "Poprzedni", today: "Dzisiaj", month: "Miesiąc", week: "Tydzień"}} culture='pl-PL' timeslots={1} events={[]} views={['month', 'week', 'day']} min={new Date('2017, 1, 7, 08:00')} max={new Date('2017, 1, 7, 20:00')} /> </div> ); } } export default NewCalendar; 循环显式游标,则不需要FOR

open/fetch/close/handle NOTFOUND

或者,您可以打开,抓取,关闭,处理... begin --open stu_c1; -- extra, not needed --Fetch stu_c1 into c_id,c_name,c_status ; -- extra, not needed for rec in stu_c1 loop -- that's enough insert into student_data values (c_status,c_id,c_name); .... end loop; --CLOSE stu_c1; -- not needed ,但不能使用NOTFOUND