cursor already open error [message #524859] |
Tue, 27 September 2011 04:16 |
|
a_sanj
Messages: 12 Registered: September 2011
|
Junior Member |
|
|
I am getting these errors..
ORA-06511: PL/SQL: cursor already open
ORA-06512: at "PCRM.PROC_EMP_SAL", line 10
ORA-06512: at "PCRM.PROC_EMP_SAL", line 17
ORA-06512: at line 1
can anyone help me in resolving it?
|
|
|
|
|
Re: cursor already open error [message #524864 is a reply to message #524862] |
Tue, 27 September 2011 04:20 |
|
a_sanj
Messages: 12 Registered: September 2011
|
Junior Member |
|
|
/* Formatted on 26-09-2011 11:20:21 (QP5 v5.115.810.9015) */
CREATE OR REPLACE PROCEDURE proc_emp_sal
IS
v_comp_mnths emp_new_sunita.comp_mnths%TYPE;
v_compltd_mnths emp_new_sunita.comp_mnths%TYPE;
--num_total_rows NUMBER;
v_new_salary emp_sunita.salary%TYPE;
CURSOR emp_sal_cur
IS
SELECT empid, name, salary, deptno, joing_date
FROM emp_sunita
WHERE func_get_date (joing_date) >= 365;
BEGIN
OPEN emp_sal_cur;
FOR emp_rec IN emp_sal_cur
LOOP
BEGIN
FETCH emp_sal_cur INTO emp_rec;
v_compltd_mnths := TRUNC (func_get_date (emp_rec.joing_date) / 12);
IF (func_get_date (emp_rec.joing_date) >= 365
AND func_get_date (emp_rec.joing_date) <= 730)
THEN
BEGIN
v_new_salary := emp_rec.salary * 1.1;
v_comp_mnths := TRUNC (func_get_date (emp_rec.joing_date) / 12);
Insert into emp_new_sunita(comp_mnths,new_salary) values(V_COMP_MNTHS,V_NEW_SALARY);
END;
ELSIF (func_get_date (emp_rec.joing_date) >= 731 AND func_get_date (emp_rec.joing_date) <= 1095)
THEN
BEGIN
v_new_salary := emp_rec.salary * 1.2;
v_comp_mnths := TRUNC (getdate (emp_rec.joing_date) / 12);
Insert into emp_new_sunita(comp_mnths,new_salary) values(V_COMP_MNTHS,V_NEW_SALARY);
END;
ELSIF (getdate (emp_rec.joing_date) >= 1096)
THEN
BEGIN
v_new_salary := emp_rec.salary * 1.3;
v_comp_mnths := TRUNC (getdate (emp_rec.joing_date) / 12);
Insert into emp_new_sunita(comp_mnths,new_salary) values(V_COMP_MNTHS,V_NEW_SALARY);
END;
END IF;
END;
Exit when emp_sal_cur%NOTFOUND;
END LOOP;
CLOSE emp_sal_cur;
END;
/
|
|
|
|
|
|
|
|
|