当触发器触发时,PL / SQL无法获得多行更新

时间:2017-12-10 20:26:38

标签: sql oracle plsql triggers sql-update

我尝试创建一个触发器,以便在另一个字段更新时更改一个字段。这是我当前的触发器,它目前有效,如果我只更新一行,但如果我更新多次,它不起作用。我该如何解决这个问题?

我顺便使用oracle。

Create or replace trigger br_change
                after update on employees
                Declare 
                    cursor pls_work is
   select e.employeeID, e.departmentID, ep.billrate, jobrank,  salary  
   from employees e full join employeeproject ep on e.employeeID
    = ep.employeeID full join jobtypes jt on jt.jobname = e.title;
                empID number(3);
                dpID number(1);
                br number(4);
                jr number(1);
                s number(12);   
            BEGIN
                open pls_work;  
                fetch pls_work into empID, dpID, br, jr, s;
                update employeeproject set billrate = ((s/2000)+(jr*10)) where empID = employeeID;
                dbms_output.put_line('Updating billrate to match changes');
        END;
        /

1 个答案:

答案 0 :(得分:0)

如果您的UPDATE语句影响多行,则需要添加FOR EACH ROW