CURSOR with dynamic condition [message #8452] |
Thu, 21 August 2003 07:47 |
fulvio
Messages: 6 Registered: March 2003
|
Junior Member |
|
|
want to change the condition of my cursor programmatically.
I have two different condition, and a cursor per condition
Declare
c1 is select prod_name ,prod_price,prod_qty*1000
from products
where ABC;
c2 is select prod_name ,prod_price,prod_qty*1000
from products
where DEF;
Is it possible to pass the string in the where condition?
Otherwise i can i do?
PLZ HELP!!
|
|
|
Re: CURSOR with dynamic condition [message #8453 is a reply to message #8452] |
Thu, 21 August 2003 13:18 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
You'll need to use dynamic SQL and explicit cursors.
create or replace procedure p(p_where in varchar2)
is
v_sql := 'select prod_name ,prod_price,prod_qty*1000
from products';
v_rc sys_refcursor; -- 9i
begin
open v_rc for v_sql || p_where;
loop
fetch v_rc into ...;
exit when v_rc%notfound;
-- do something
end loop;
close v_rc;
end;
|
|
|