注册 登录
编程论坛 Oracle论坛

看看我写的程序包那里错了

毛蛋 发布于 2008-03-24 19:00, 1430 次点击
表my_toys
id  varchar2(5)
name varchar2(20)
price  number

create or replace package body toyspack
  as
  procedure UpdateToyPrice IS
  avg_price number;
  fact_price number;
begin
  loop
  SELECT AVG(price),price INTO avg_price,fact_price FROM my_toys;
    if avg_price<400 then
       update my_toys set price=price*1.1 where price<=500;
    else
       exit;
    end if;
  end loop;
  end UpdateToyPrice;          ----------------过程结束
  function AvgToyPrice       ----------------函数开始
    return varchar2
  IS
    avg_price number;
    fact_price number;
  begin
   loop
     SELECT AVG(price),price INTO avg_price,fact_price FROM my_toys;
     if avg_price<400 then
        update my_toys set price=price*1.1 where price<=500;
     else
        return '函数执行完成!';
     end if;
    end loop;
  end AvgToyPrice;
end toyspack;
/
1 回复
1