1. 好像不需要函数了,除非你的税金的计算很复杂,那你就写一个根据工资算税金的函数。  insert into tax_table (id,name,tax)
  ( select id,name,(salary - 1000) * 0.1 from base_table );2.
create or replace trigger base_update
before update of sal_level on base_table
for each row
begin
  :new.salary := :old.salary + (:new.sal_level - :old.sal_level) * 500;
end;
/

解决方案 »

  1.   

    虽说不用函数也可以做出,
    不过我主要是为了学PL/SQL
    来了解一下函数和过程的写法,
    谢谢  Lastdrop(空杯) ( ) 
     
    所以还是想用函数做出来。
    (因为才看PL/SQL几天,只能看得懂语法,而这方面能够比较快上手的资料不多,
    所以想看一下怎么用函数做。)
      

  2.   

    过程如下:
    create or procedure c_table(p_id in varchar2)
    as
    begin
    update tax_table a (tax)=( select (salary - 1000) * 0.1 from base_table where a.id=id and id=p_id);
    end;
    /
    函数也大同小异,只是函数要返回值.