2012-11-25 79 views
1

我在這裏有一個小小的棘手問題。我有2個表:SQL(Oracle)中的兩個表的過程

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

我試圖改變表employee獎金,根據使用的程序的性能。

這是我迄今所做的:

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; 

的問題是,我不知道如何把到程序表employee_performance

回答

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; 
+0

謝謝,這個錯誤出現,但 - >錯誤(9,11):PL/SQL:ORA-00936:缺少表達 –

+0

我想我找到了,謝謝,你是把一個更並不需要 –

+0

@TmsJns謝謝,糾正它... – Yahia