For 变量 in 循环开始的值 .. 循环结束的值(小于该值)
Loop
--做处理的语句
End Loop
例子:
---循环找出供应商
for i in 0 .. vendor_Total loop -- i 和 vendor_Total 在存储过程头部定义,vendor_Total 在循环之前已经赋值
if i = vendor_Total then
str_vendor := substr(str_vendors, 0, length(str_vendors));
str_VASSIGN := substr(str_VASSIGNs, 0, length(str_VASSIGNs));
else
vendor_index := instr(str_vendors, ':');
vassign_index := instr(str_VASSIGNs, ':');
str_vendor := substr(str_vendors, 0, vendor_index - 1);
str_VASSIGN := substr(str_VASSIGNs, 0, vassign_index - 1);
end if;
---start插入数据--
select SEQ_VASSIGNLINEID.nextval into str_LINEID from dual;
insert into VASSIGNFORMDETAIL
(ASSIGNSCALE,
VENDORCODE,
ASSIGNCODE,
ASSIGNPERCENT,
CREATEUSER,
CREATEDATE,
CREATETIME,
FORMID,
FORMNO,
LINEID,
REMARK)
values
(to_number(str_VASSIGN),
str_vendor,
str_ASSIGNCODE,
to_number(str_VASSIGN) * 10,
createuser_in,
to_number(to_char(sysdate, 'yyyymmdd')),
to_number(to_char(sysdate, 'hh24MMSS')),
str_vassignformid,
str_ASSIGNCODE,
str_LINEID,
to_char(sysdate) || '批量导入');
---end 插入数据--
str_vendors := substr(str_vendors,
vendor_index + 1,
length(str_vendors) - vendor_index);
str_VASSIGNs := substr(str_VASSIGNs,
vassign_index + 1,
length(str_VASSIGNs) - vassign_index);
end loop;