Pl/sql lets you refer to the most recent implicit cursors as the sql cursor. Closing a Cursor The cursor must be initialized or opened with the open statement.
The solution to mutating problem is explained at : Work around for mutating problem in Oracle Triggers. create or replace trigger trg_log_job_change after update of job_id on employees for each row declare v_enddate date; v_startdate date; begin -- find out whether the employee has any row in job_history table select max(end_date) into v_enddate from job_history where employee_id = :old.employee_id; if v_enddate is null then v_startdate := :old.hire_date; else v_startdate := v_enddate 1; end if; insert into job_history values (:old.employee_id, v_startdate, sysdate, :old.job_id, :old.department_id); end; Note: Before testing the above trigger, you need to disable UPDATE_JOB_HISTORY trigger, which is already present in HR account, as it does the same.
create table Employee( 2 ID VARCHAR2(4 BYTE) NOT NULL primary key, 3 First_Name VARCHAR2(10 BYTE), 4 Last_Name VARCHAR2(10 BYTE), 5 Start_Date DATE, 6 End_Date DATE, 7 Salary Number(8,2), 8 City VARCHAR2(10 BYTE), 9 Description VARCHAR2(15 BYTE) 10 ) 11 / Table created.
All employees from department 40 will have a 10% increase while employees from department 70 will have 15% increase.
I have 1 employee from department 70 who has a salary of 10000 so he will have a 15% increase.
using a cursor we can fetch all the row values from the table into a variable for printing them or performing some action with them In an explicit cursor, there are four steps related to execute cursors by the user. Write a program using an explicit cursor, which displays all the rows from the table Declare Cursor c1 is select * from emp; e emp%rowtype; Begin Open c1; Loop Fetch c1 into e; Dbms_output.put_line(e.empno||' '||e.ename||' '||e.sal); Exit when c1%notfound; End loop; Close c1; End; / 2.