编程论坛's Archiver

毛蛋 发表于 2008-3-24 19:00

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

表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]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.