调用存储过程时,参数是一个vo1 ,vo1里面定义了一个 List, 现在需要将 vo中的数据插入到 a表中,将List 中的数据批量插入到 b表中,这个存储过程要怎么写啊,求助。。。
1条回答
- xwh1314 2018-03-19 03:13关注
create procedure p_pldr_test
(
v_a001 varchar(20),
v_end smallint, --结束标记(等于 1 时为结束)
inout v_only varchar(36), --唯一值(等于''时为第一条记录)
inout v_ret smallint --返回值:0-成功,98-部分不成功
)
begin
if v_only is null then
set v_only=f_newid();
end if;
if v_end <> 1 then
insert into tmp_c(s_id, value1)
values(trim(v_only),v_a001);
set v_ret= 0;
return;
end if;
begin
declare v_cnt smallint;
declare tmp_cur cursor is select value1 from tmp_c where s_id = trim(v_only) ;
open tmp_cur;
loop_tmp_cur:
loop
fetch tmp_cur into v_a001;
insert into b(id,a000,a001)
select nextval id,a001 from a where a001 = v_a001 ;
end loop loop_tmp_cur;
close tmp_cur ;--select count(*) into v_cnt from a ;
--if v_cnt <> 0 then
-- set v_ret=98 ;
--else
-- set v_ret=0 ;
--end if ;
commit;
end;解决 无用评论 打赏 举报