1.在存储过程中 定义游标;
以“cur_yjdl ”为例
create or replace procedure fnStat1399(p_params varchar2,
p_cursor1401 out sys_refcursor,
p_partId Integer ) is
NYDMJ varchar2(100);
JSYDMJ varchar2(100);
WLYDMJ varchar2(100);
--定义 游标cur_yjdl
CURSOR cur_yjdl IS select dlm,yjmj from TDLYXZ
begin
--清空原来数据
delete from DLFXZY where humanId = p_partId;
--2.循环游标取数据
for yjdl in cur_yjdl loop
if yjdl.DLM = 1 --使用dlm字段,yjdl.dlm
then NYDMJ := yjdl.yjmj * 0.0015; --使用yimj字段,yjdl.yimj
elsif yjdl.DLM = 2
then JSYDMJ := yjdl.yjmj * 0.0015;
else WLYDMJ := yjdl.yjmj * 0.0015;
end if;
end loop;
--表里插入数据
insert into DLFXZY(humanID,NYDMJ,JSYDMJ,WLYDMJ) values(p_partId,NYDMJ,JSYDMJ,WLYDMJ);
open p_cursor1401 for select NYDMJ,JSYDMJ,WLYDMJ from DLFXZY where humanId = p_partId;
end;