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;

解决方案 »

  1.   

    没做事务提交,怎样提交你自己看咯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);
             
               commit;
            
             end loop;
            close filmtoblog;
     end;
      

  2.   

    加上commit。死在那里?确定是死了吗?也许表数据多,执行慢吧。
      

  3.   

    表中的数据不多,只有20条,执行了很久都没反应,应该是死了吧,死在哪里怎么看的???
    我刚刚用PL/SQL Developer.
      

  4.   

    declare
            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;
      

  5.   

    改为下面的试一下 begin
            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;