Plsql procedure for updating salary which is greater than 10000

So I will start with one of the most common types of data: strings.

Very few database tables and programs do , is a sequence of selected symbols from a particular set of characters.

In other words, the symbols in a string might consist of English letters, such as ”A” or ”B.” They might also consist of Chinese characters, such as 字串.

By default, a trigger is created in the enabled state.

You should put the DECLARE CURSOR cur_emp IS SELECT * FROM employees WHERE department_id = 40 OR department_id = 70; rec_emp cur_emp%rowtype; BEGIN OPEN cur_emp; LOOP FETCH cur_emp INTO rec_emp; EXIT WHEN cur_emp%notfound; -- **** leave the loop right here, BEFORE doing the update ***** IF rec_emp.department_id = 40 THEN UPDATE employees SET salary = salary (salary * 0.1) WHERE employee_id = rec_emp.employee_id; elsif rec_emp.department_id = 70 THEN UPDATE employees SET salary = salary (salary * 0.15) WHERE employee_id = rec_emp.employee_id; END IF; END LOOP; CLOSE cur_emp; END; / DECLARE CURSOR cur_emp IS SELECT department_id, salary FROM employees WHERE department_id in (40,70) FOR UPDATE OF salary; rec_emp cur_emp%rowtype; new_sal number(12,2); BEGIN OPEN cur_emp; LOOP FETCH cur_emp INTO rec_emp; EXIT WHEN cur_emp%NOTFOUND; IF rec_emp.department_id = 40 THEN new_sal := rec_emp.salary * 1.10; elsif rec_emp.department_id = 70 THEN new_sal := rec_emp.salary * 1.15; END IF; UPDATE employees SET salary = new_sal WHERE CURRENT OF cur_emp; END LOOP; CLOSE cur_emp; END; / Seems strange that you are required to use a cursor?

If you still need to investigate the cause of your problem I should recommend you to add some trace messages into the code (with e.g.

When a trigger fires, tables that the trigger references might be undergoing changes made by SQL statements in other users' transactions.

SQL statements running in triggers follow the same rules that standalone SQL statements do.

Leave a Reply