+ -
当前位置:首页 → 问答吧 → oracle 9i中 while语句报错问题

oracle 9i中 while语句报错问题

时间:2011-12-19

来源:互联网

我向给数据库中造上一批数据,写了存储过程,但WHILE语句总是报错,寻找大侠级解决办法。
1、语句:
create or replace procedure insertDate as 
BEGIN
  DECLARE monthly_value number;
  number monthly_value:= 0;
 
  while monthly_value < 100000 LOOP

  insert into student values(monthly_value,monthly_value);
  commit; 
  monthly_valuei:=monthly_value + 1;
  dbms_output.put_line(i);
  END LOOP;
END;
2、错误信息如下:

PROCEDURE WNJW.INSERTDATE 编译错误

错误:PLS-00103: 出现符号 "<"在需要下列之一时:
  := . ( @ % ; not null range
  default character
行:6
文本:while monthly_value < 100000 LOOP

错误:提示: Variable 'while' 已被声明但从来没有被用于 'insertDate'
行:6
文本:while monthly_value < 100000 LOOP

错误:提示: Variable 'monthly_valuei' 已被声明但从来没有被用于 'insertDate'
行:9
文本:monthly_valuei:=monthly_value + 1;

作者: tih_w   发布时间: 2011-12-19

SQL code

这样就好了啊:
create or replace procedure insertdate as  
monthly_value number:=0;
begin
    while monthly_value<10 
    loop
            monthly_value:=monthly_value+1;
            insert into b values('7','123');
            dbms_output.put_line(monthly_value);
    end loop;
    commit;
end;

作者: zyuc_wangxw   发布时间: 2011-12-19

create or replace procedure insertdate as  
monthly_value number:=0;
begin
while monthly_value<100000 
loop
monthly_value:=monthly_value+1;
insert into student values(monthly_value,monthly_value);
dbms_output.put_line(monthly_value);
end loop;
commit;
end;

作者: zyuc_wangxw   发布时间: 2011-12-19