create or replace procedure sp_xmqkg0
as
  declare
  cursor c_tb_xmqkg0
  is  
  select CED001,AAC003
  from eaa1
begin
  for r in c_tb_xmqkg0 loop   
  UPDATE eaa1 SET AAC003 = REPLACE(AAC003,' ','') as 现在姓名
  then
  insert into tb_xmqkg0_bak  
  VALUES(r.CED001,r.AAC003,现在姓名);    
  end if;
  end loop;
  commit;
  exception
  when others
  then  
  rollback;
end;    有哪里错误?谢谢

解决方案 »

  1.   

    错误很多~~ cursor c_tb_xmqkg0
      is   
      select CED001,AAC003
      from eaa1
    少个分号没有if  却出来了 then  和  end if
      

  2.   

    正解还有 UPDATE eaa1 SET AAC003 = REPLACE(AAC003,' ','') as 现在姓名  这句后面怎么会有个then
    insert语句写了values却没写insert的列名
      

  3.   

    你这代码是copy别人出来的吧,N多错误
      

  4.   

    create or replace procedure sp_xmqkg0
    is
      
      v_number number :=0;
      cursor c_tb_xmqkg0
      is  
      select ced001,aac003
      from eaa1;
    begin
      for r in c_tb_xmqkg0 loop   
      select count(*) into v_number from eaa1 where ced001 =r.ced001;
      update eaa1 set aac003=replace(replace(aac003,' ',''),'  ','');
      if v_number>0 then
      insert into tb_xmqkg0_bak(个人档案号,原来姓名) VALUES(r.ced001,r.aac003);    
      end if;
      end loop;
      commit;
      exception
      when others
      then  
      rollback;
    end sp_xmqkg0;