Quote:
Originally posted by senthil5_kumar
Hi,
In PL/SQL procedure I am using a IN parmater in the where condition of the declared cursor. when I see the output it returns all the rows from the table without filtering the records using the where condition.
should I not use the IN parameter in the cursor declaration.
I have used the following procedure.
CREATE OR REPLACE PROCEDURE empProc2
(empno IN NUMBER)
IS
BEGIN
DECLARE
no NUMBER(5);
name VARCHAR2(50);
CURSOR emp_cur IS
SELECT empno,name FROM emp where empno = empno;
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur
INTO no,
name;
EXIT WHEN emp_cur%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(no||'|'||name);
END LOOP;
CLOSE emp_cur;
END;
END;
/
Can some one help me to resolve this
Thanks in advance
Regards,
Senthil
|
Hi,
You are getting this error because your in parameter variable name is same as the column name.
That is when the following SQL is executed,
SELECT empno,name FROM emp where empno = empno;
The SQL tries to equate the empno column with the empno
column and NOT the in parameter empno.
Solution for this would be use the IN parameter name as in_empno.
Hope it Helps