newbieexpert
asked on
pass parameter to procedure to use in cursor
Hello experts,
I would need to pass a parameter value to a cursor in a pl/sql procedure.
create or replace procedure test1
cursor c as select * from emp where emp_name = 'test'
instead of above can we do it this way ? I am getting an error with this approach can you please help with the correct syntax in doing or give me an example please.
create or replace procedure test1 (p_empname in varchar2(20))
cursor c as select * from emp where emp_name = p_empname
Thank you!
I would need to pass a parameter value to a cursor in a pl/sql procedure.
create or replace procedure test1
cursor c as select * from emp where emp_name = 'test'
instead of above can we do it this way ? I am getting an error with this approach can you please help with the correct syntax in doing or give me an example please.
create or replace procedure test1 (p_empname in varchar2(20))
cursor c as select * from emp where emp_name = p_empname
Thank you!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm curious, what will you use a procedure like this for? Usually it is not a good idea to write cursors like:
select * from ... [a table]
since if the table definition ever changes, your procedure will need to be re-compiled (and/or changed, then recompiled).
select * from ... [a table]
since if the table definition ever changes, your procedure will need to be re-compiled (and/or changed, then recompiled).
ASKER