DB2添加大量数据的存储过程
CREATE or replace PROCEDURE insert_NUM ()
DYNAMIC RESULT SETS 1
P1: BEGIN
-- Declare cursor
declare a int;
set a=1;
loop1:
LOOP
if(a<=1000000) then
insert into user(name,age,sex)
values ('李四' || a ,MOD(a,100),case when mod(a,100)=1 then '男' else '女' end);
set a=a+1;
else
leave loop1;
end if;
end loop loop1;
END P1
说明:MOD是取余函数