declare
title varchar2(256);
userid number;
status number;
statustime date;
cursor filmtoblog is
select filmname,createuser,status,statustime from pmhfilmdocs;
begin
open filmtoblog;
loop
fetch filmtoblog into title,userid,status,statustime;
exit when filmtoblog%notfound;
insert into pmhuserblog(blogid,title,userid,status,statustime) values (f_getprimarykey('pmhuserblog.blogid'),title,userid,status,statustime);
end loop;
close filmtoblog;
end;
title varchar2(256);
userid number;
status number;
statustime date;
cursor filmtoblog is
select filmname,createuser,status,statustime from pmhfilmdocs;
begin
open filmtoblog;
loop
fetch filmtoblog into title,userid,status,statustime;
exit when filmtoblog%notfound;
insert into pmhuserblog(blogid,title,userid,status,statustime) values (f_getprimarykey('pmhuserblog.blogid'),title,userid,status,statustime);
end loop;
close filmtoblog;
end;
title varchar2(256);
userid number;
status number;
statustime date;
cursor filmtoblog is
select filmname,createuser,status,statustime from pmhfilmdocs;
begin
open filmtoblog;
loop
fetch filmtoblog into title,userid,status,statustime;
exit when filmtoblog%notfound;
insert into pmhuserblog(blogid,title,userid,status,statustime) values (f_getprimarykey('pmhuserblog.blogid'),title,userid,status,statustime);
commit;
end loop;
close filmtoblog;
end;
我刚刚用PL/SQL Developer.
title varchar2(256);
userid number;
status number;
statustime date;
cursor filmtoblog is
select filmname,createuser,status,statustime from pmhfilmdocs;
begin
open filmtoblog;-----打开游标之后要fetch再loop
loop -----不会进入循环
fetch filmtoblog into title,userid,status,statustime;
exit when filmtoblog%notfound;
insert into pmhuserblog(blogid,title,userid,status,statustime) values (f_getprimarykey('pmhuserblog.blogid'),title,userid,status,statustime);
end loop;
close filmtoblog;
end;
open filmtoblog;
fetch filmtoblog into title,userid,status,statustime;
loop
exit when filmtoblog%notfound;
insert into pmhuserblog(blogid,title,userid,status,statustime) values (f_getprimarykey('pmhuserblog.blogid'),title,userid,status,statustime);
fetch filmtoblog into title,userid,status,statustime;
end loop;
close filmtoblog;
commit;
end;