1

我这里有一个棘手的小问题。我有 2 张桌子:

employee(id,salary,bonus) 
employee_performance(id,gain,year) .

我正在尝试employee根据使用过程的性能更改 table 上的奖金。

这是我到目前为止所做的:

create or replace procedure name_of_proc 
AS
BEGIN
   update employee e
      set e.bonus = e.bonus - 900
   where e.salary >= 2000 
     and employee_performance.gain <=2000 
     and employee_performance.year = 2012 
     and e.id=employee_performance.id;
END;

问题是我不知道如何将 table 放入程序中employee_performance

4

1 回答 1

1

尝试

create or replace procedure name_of_proc 
AS
BEGIN
   update employee e
      set e.bonus = e.bonus - 900
   where e.salary >= 2000 
     and e.id in 
         (select ep.id from employee_performance ep where ep.gain <=2000 
          and ep.year = 2012
          and ep.id = e.id
         );
END;
于 2012-11-25T12:10:14.437 回答