Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4043044
  • 博文数量: 536
  • 博客积分: 10470
  • 博客等级: 上将
  • 技术积分: 4825
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-26 14:08
文章分类

全部博文(536)

文章存档

2024年(3)

2021年(1)

2019年(1)

2017年(1)

2016年(2)

2013年(2)

2012年(10)

2011年(43)

2010年(10)

2009年(17)

2008年(121)

2007年(252)

2006年(73)

分类: Oracle

2007-03-23 16:24:51

CREATE OR REPLACE PROCEDURE TEST_PROCPROC4(t IN NUMBER) AS
  TYPE t_int IS VARRAY(10) OF NUMBER;
  TYPE t_mint IS VARRAY(10) OF t_int;
  TYPE t_tab IS TABLE OF VARCHAR2(50);
  TYPE t_mtab IS TABLE OF t_tab;
  TYPE t_itab IS TABLE OF t_int;
  sint t_int := t_int(12);
  smint t_mint := t_mint(sint); stab t_tab; smtab t_mtab; sitab t_itab;
  tc INTEGER := 10; tr INTEGER := 9;
BEGIN
  sint := t_int();
  stab := t_tab();
  smint := t_mint();
  smtab := t_mtab();
  sitab := t_itab();

  sint.EXTEND(tc);
  stab.EXTEND(tc);
  smint.EXTEND(tc);
  smtab.EXTEND(tc);
  sitab.EXTEND(tc);

  FOR i IN 1 .. tc LOOP
    sint(i) := 9;
    stab(i) := '#@!Tsadf2030071546';

    smint(i) := t_int();
    smtab(i) := t_tab();
    sitab(i) := t_int();
    smint(i).EXTEND(tr);
    smtab(i).EXTEND(tr);
    sitab(i).EXTEND(tr);
    FOR j IN 1 .. tr LOOP
      smint(i)(j) := 995;
      smtab(i)(j) := 'eASF';
      sitab(i)(j) := 2868;
    END LOOP;
  END LOOP;
  FOR i IN 1 .. tc LOOP
    EXECUTE IMMEDIATE 'INSERT INTO TEST_4SP.TEST_PROC(COL_0)
      VALUES(:1)'
USING sint(1)+t;
  END LOOP;
END;
/


Increasing the Size of a Collection (EXTEND Method)

To increase the size of a nested table or varray, use EXTEND.
This procedure has three forms:
     EXTEND appends one null element to a collection.
     EXTEND(n) appends n null elements to a collection.
     EXTEND(n,i) appends n copies of the ith element to a collection.
  You cannot use EXTEND with index-by tables. You cannot use EXTEND to add elements to an uninitialized collection. If you impose the NOT NULL constraint on a TABLE or VARRAY type, you cannot apply the first two forms of EXTEND to collections of that type.
  EXTEND operates on the internal size of a collection, which includes any deleted elements. This refers to deleted elements after using DELETE(n), but not DELETE without parameters which completely removes all elements. If EXTEND encounters deleted elements, it includes them in its tally. PL/SQL keeps placeholders for deleted elements, so that you can re-create them by assigning new values.
阅读(1625) | 评论(0) | 转发(0) |
0

上一篇:Oracle ORA-25153

下一篇:如何撰写商业计划

给主人留下些什么吧!~~