--定义cursor
cursor cuhdr(run_number number, unit number) is
select * from plsql_profiler_units
where runid = run_number and unit_number = unit;
unit_row cuhdr%rowtype;....
--打开cursor
open cuhdr(run_number, unit);
--取数
fetch cuhdr into unit_row;
--关闭cursor
close cuhdr;
==================================================
my work example:
create or replace function query_available_lines(p_serial_num in varchar2,
p_query_type in varchar2)
return varchar2 is
----------------------------------------------
cursor available_krh_line(p_sn varchar2) is(
select line_id
from work_order woa
where woa.order_state = 1
and woa.order_type = 'KRH'
and woa.pid in
(select pid
from product_level pl
where pl.child_pid in
(select (select pid
from product_maintain pm
where pm.product_number = ls.product_number
and pm.rstate = ls.rstate) newpid
from label_sn ls
where ls.sn = p_sn)));
cur_row available_krh_line%rowtype;
-----------------------------------------------------
v_result_lines varchar2(1000) := ' ';
--------------------------------------------------------------
begin
if p_query_type = 1 then
----------------Return KRH level available line----
open available_krh_line(p_serial_num);
loop
fetch available_krh_line
into cur_row;
exit when available_krh_line%notfound;
v_result_lines := v_result_lines || '#' || cur_row.line_id;
end loop;
close available_krh_line;