Link to home
Start Free TrialLog in
Avatar of newbieexpert
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!
SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of newbieexpert
newbieexpert

ASKER

Thank you very much!!!
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).