视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
oracle 10g values of 和indices of 初次接触
2025-09-25 23:11:01 责编:小OO
文档
values of 和indices of是oracle 10g的新特性。在批量处理中提高性能,适用于处理嵌套集合,稀疏集合时,以避免丢失记录异常和创建多余副本。

在使用时,

forall var in values of collection 的 collection定义需要为var的类型。

forall var inindices ofcollection 的collection定义可以使其他对象,这里的var相当于collection的下标

create or replace procedure p_product_price_ex(p_company varchar2) is

type t_product_id is table of product.product_id%type index by pls_integer;

type t_yyyy is table of product.yyyy%type index by pls_integer;

--type t_price is table of product.price%type index by pls_integer;

TYPE t_partions IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;

v_product_id t_product_id;

v_yyyy t_yyyy;

--v_price t_price;

v_down_list t_partions;

v_up_list t_partions;

procedure p_retrive_datas is

v_sql varchar2(256);

begin

select p.product_id, p.yyyy bulk collect

into v_product_id, v_yyyy

from product_1 p

where p.company = p_company;

end;

procedure p_partition_datas is

begin

for i in v_product_id.first .. v_product_id.last loop

if mod(v_product_id(i), 2) = 0 then

v_down_list(i) := i;

else

v_up_list(i) := i;

end if;

end loop;

end;

procedure p_product_price_down is

begin

forall j in values of v_down_list

insert into product_down (product_id) values (v_product_id(j));

commit;

end;

procedure p_product_price_up is

begin

forall k in values of v_up_list

insert into product_up (product_id) values (v_product_id(k));

commit;

end;

begin

p_retrive_datas;

p_partition_datas;

p_product_price_down;

p_product_price_up;

end;

create or replace procedure p_product_price_ex2(p_company varchar2) is

type t_product_id is table of product.product_id%type index by pls_integer;

type t_yyyy is table of product.yyyy%type index by pls_integer;

v_product_id t_product_id;

v_yyyy t_yyyy;

TYPE guide_aat IS TABLE OF BOOLEAN INDEX BY PLS_INTEGER;

v_down_list guide_aat;

v_up_list guide_aat;

procedure p_retrive_datas is

v_sql varchar2(256);

begin

select p.product_id, p.yyyy bulk collect

into v_product_id, v_yyyy

from product_1 p

where p.company = p_company;

end;

procedure p_partition_datas is

begin

for i in v_product_id.first .. v_product_id.last loop

if mod(v_product_id(i), 2) = 0 then

v_down_list(i) := TRUE;

else

v_up_list(i) := TRUE;

end if;

end loop;

end;

procedure p_product_price_down is

begin

forall j in INDICES of v_down_list

insert into product_down (product_id) values (v_product_id(j));

commit;

end;

procedure p_product_price_up is

begin

forall k in INDICES of v_up_list

insert into product_u

p (product_id) values (v_product_id(k));

commit;

end;

begin

p_retrive_datas;

p_partition_datas;

p_product_price_down;

p_product_price_up;

end;下载本文

显示全文
专题