日期:2014-05-17  浏览次数:20975 次

存储过程的循环中有sql就出错误。
create or replace procedure reset_seq
is
  l_val number;
  num number;
  Cursor cur_seq is select squencename from codeinfo order by codeinfo_id;
  squ_name varchar2(50);
begin
  for squ_name in cur_seq loop

  select count(1) INTO num from All_Sequences where Sequences_name= squ_name.squencename ;
  if num > 0 then
  execute immediate
  'select ' || squ_name.squencename || '.nextval from dual' INTO l_val;

  execute immediate
  'alter sequence ' || squ_name.squencename || ' increment by -' || l_val || ' minvalue 0';
  execute immediate
  'select ' || squ_name.squencename || '.nextval from dual' INTO l_val;
  execute immediate
  'alter sequence ' || squ_name.squencename || ' increment by 1 minvalue 0';
  end if;
  end loop;
end ;
只要循环里加了红色的那个sql语句就出错,求各位大牛给看下。


------解决方案--------------------
from All_Sequences where Sequences_name

如果这个是系统视图 ,那就是字段写错了

 Sequence_name 不是 Sequences_name