0
CREATE OR REPLACE PROCEDURE calc_bonus()

IS

    var_bonus_rate FLOAT;
    var_emp_record emp%ROWTYPE;
    var_years_worked int;

    CURSOR cur_emp IS
    SELECT *
    FROM emp
    WHERE emp <> 'Pres';

BEGIN

OPEN emp_cur;
LOOP
    FETCH cur_emp INTO var_emp_record;
    EXIT WHEN cur_emp%NOTFOUND;
    var_bonus_rate := 0.1;


    IF (var_years_worked > 10) THEN
        var_bonus_rate := var_bonus_rate + 0.1;
    ELSIF (var_years_worked > 5) THEN
        var_bonus_rate := var_bonus_rate + 0.05;
    END IF;

    IF var_emp_record.job = 'Designer' THEN
        var_bonus_rate := var_bonus_rate + 0.15;
    ELSIF var_emp_record.job = 'Manager' THEN
        var_bonus_rate := var_bonus_rate + 0.1;
    END IF;

UPDATE emp e2
SET e2.bonus = e2.salary * var_bonus_rate;

END LOOP;

CLOSE emp_cur;

END;
/

我收到的错误

1/22     PLS-00103: Encountered the symbol ")" when expecting one of the
     following:
     <an identifier> <a double-quoted delimited-identifier>
     current delete exists prior
4

1 回答 1

0

CREATE OR REPLACE PROCEDURE calc_bonus()- 这是错误的原因。删除括号或添加一些参数。你的选择是

 1. CREATE OR REPLACE PROCEDURE calc_bonus is
 2. CREATE OR REPLACE PROCEDURE calc_bonus(p_Param1 datatype, ... 
                                         , p_paramN datatype) is
于 2012-09-13T06:20:54.840 回答