数组定义:
type t_number is varray (100) of number not null;
举例:
create or replace function gettaxfeeforreport(p_stanid number,p_id varchar2,p_expectfield varchar2) return varchar2
is
/*
函数功能:通过业务编号汇总出该业务的税费信息。
函数版本:
v_20090424 每次最多移交100笔业务
*/
-- type t_numberstab is table of number;
-- v_idlist t_numberstab:=t_numberstab();
type t_number is varray (100) of number not null;
v_idlist t_number:=t_number(0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0);
v_cnt number:=0;
v_seq number:=1;
v_id varchar2(4000):='';
n_id number;
v_returninfo varchar2(4000):='';
begin
v_id:=p_id;
loop
select instr(v_id,',') into v_cnt from dual;
if v_cnt=0 then
-- v_idlist.extend;
v_idlist(v_seq):=to_number(v_id);
exit;
else
select to_number(substr(v_id,1,v_cnt-1)) into n_id from dual;
select substr(v_id,v_cnt+1) into v_id from dual;
-- v_idlist.extend;
v_idlist(v_seq):=n_id;
v_seq:=v_seq+1;
end if;
end loop;
select '税费合计:'||nvl(sum(receivetaxfee),0)||'元 ' into v_returninfo from taxfeedetail where activeid in (v_idlist(1),v_idlist(2),v_idlist(3),v_idlist(4),v_idlist(5),v_idlist(6),v_idlist(7),v_idlist(8),v_idlist(9),v_idlist(10),
v_idlist(11),v_idlist(12),v_idlist(13),v_idlist(14),v_idlist(15),v_idlist(16),v_idlist(17),v_idlist(18),v_idlist(19),v_idlist(20),
v_idlist(21),v_idlist(22),v_idlist(23),v_idlist(24),v_idlist(25),v_idlist(26),v_idlist(27),v_idlist(28),v_idlist(29),v_idlist(30),
v_idlist(31),v_idlist(32),v_idlist(33),v_idlist(34),v_idlist(35),v_idlist(36),v_idlist(37),v_idlist(38),v_idlist(39),v_idlist(40),
v_idlist(41),v_idlist(42),v_idlist(43),v_idlist(44),v_idlist(45),v_idlist(46),v_idlist(47),v_idlist(48),v_idlist(49),v_idlist(50),
v_idlist(51),v_idlist(52),v_idlist(53),v_idlist(54),v_idlist(55),v_idlist(56),v_idlist(57),v_idlist(58),v_idlist(59),v_idlist(60),
v_idlist(61),v_idlist(62),v_idlist(63),v_idlist(64),v_idlist(65),v_idlist(66),v_idlist(67),v_idlist(68),v_idlist(69),v_idlist(70),
v_idlist(71),v_idlist(72),v_idlist(73),v_idlist(74),v_idlist(75),v_idlist(76),v_idlist(77),v_idlist(78),v_idlist(79),v_idlist(80),
v_idlist(81),v_idlist(82),v_idlist(83),v_idlist(84),v_idlist(85),v_idlist(86),v_idlist(87),v_idlist(88),v_idlist(89),v_idlist(90),
v_idlist(91),v_idlist(92),v_idlist(93),v_idlist(94),v_idlist(95),v_idlist(96),v_idlist(97),v_idlist(98),v_idlist(99),v_idlist(100));
for taxrs in ( select (select tfname from taxfeedefine tf where tf.taxfeedefineid=tfd.taxfeedefineid) taxfeedefineid,sum(receivetaxfee) receivetaxfee from taxfeedetail tfd where activeid in (v_idlist(1),v_idlist(2),v_idlist(3),v_idlist(4),v_idlist(5),v_idlist(6),v_idlist(7),v_idlist(8),v_idlist(9),v_idlist(10),
v_idlist(11),v_idlist(12),v_idlist(13),v_idlist(14),v_idlist(15),v_idlist(16),v_idlist(17),v_idlist(18),v_idlist(19),v_idlist(20),
v_idlist(21),v_idlist(22),v_idlist(23),v_idlist(24),v_idlist(25),v_idlist(26),v_idlist(27),v_idlist(28),v_idlist(29),v_idlist(30),
v_idlist(31),v_idlist(32),v_idlist(33),v_idlist(34),v_idlist(35),v_idlist(36),v_idlist(37),v_idlist(38),v_idlist(39),v_idlist(40),
v_idlist(41),v_idlist(42),v_idlist(43),v_idlist(44),v_idlist(45),v_idlist(46),v_idlist(47),v_idlist(48),v_idlist(49),v_idlist(50),
v_idlist(51),v_idlist(52),v_idlist(53),v_idlist(54),v_idlist(55),v_idlist(56),v_idlist(57),v_idlist(58),v_idlist(59),v_idlist(60),
v_idlist(61),v_idlist(62),v_idlist(63),v_idlist(64),v_idlist(65),v_idlist(66),v_idlist(67),v_idlist(68),v_idlist(69),v_idlist(70),
v_idlist(71),v_idlist(72),v_idlist(73),v_idlist(74),v_idlist(75),v_idlist(76),v_idlist(77),v_idlist(78),v_idlist(79),v_idlist(80),
v_idlist(81),v_idlist(82),v_idlist(83),v_idlist(84),v_idlist(85),v_idlist(86),v_idlist(87),v_idlist(88),v_idlist(89),v_idlist(90),
v_idlist(91),v_idlist(92),v_idlist(93),v_idlist(94),v_idlist(95),v_idlist(96),v_idlist(97),v_idlist(98),v_idlist(99),v_idlist(100)) and receivetaxfee>0 group by taxfeedefineid)
loop
if v_cnt=0 then
v_returninfo:=v_returninfo||'其中:'||taxrs.taxfeedefineid||taxrs.receivetaxfee||'元';
else
v_returninfo:=v_returninfo||','||taxrs.taxfeedefineid||taxrs.receivetaxfee||'元';
end if;
v_cnt:=v_cnt+1;
end loop;
return v_returninfo;
end gettaxfeeforreport;
/
show err;