Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL type table index by binary_integer -- auto initialization??

PL/SQL type table index by binary_integer -- auto initialization??

From: Martin T. <bilbothebagginsbab5_at_freenet.de>
Date: 12 Sep 2006 02:23:12 -0700
Message-ID: <1158052991.970334.74960@e63g2000cwd.googlegroups.com>


Hi all.
(Oracle 9.2.0.1.0, Windows XP)

All documentation I've found states that you have to initialize a "record" in a PL/SQL type table (via extend) to use it.

However consider the following script:

---
DECLARE
  TYPE char_table IS TABLE OF VARCHAR2(1000);
  TYPE char_idx_table IS TABLE OF VARCHAR2(1000) INDEX BY
BINARY_INTEGER;
  v_t1 char_table;
  v_t2 char_idx_table;
  v_t1_2 char_table := char_table();
BEGIN
  FOR rec IN (
  SELECT rownum row_number, object_id, object_name FROM ALL_OBJECTS
WHERE rownum < 20 )
  LOOP

/* This works! */
v_t2(rec.object_id) := rec.object_name;
/* Correct output: */
dbms_output.put_line('Set '||rec.object_id||' to '||v_t2(rec.object_id)||' ...');
/* ORA-06531: Reference to uninitialized collection: */
--v_t1(rec.object_id) := rec.object_name;
/* ORA-06533: Subscript beyond count */
-- v_t1_2(rec.object_id) := rec.object_name; v_t1_2.extend;
/* ORA-06533: Subscript beyond count */
-- v_t1_2(rec.object_id) := rec.object_name;
/* This works (in combination with the extend above) */
v_t1_2(rec.row_number) := rec.object_name; END LOOP; END; / --- Can someone tell me where this behaviour is documented? thanks! best, Martin
Received on Tue Sep 12 2006 - 04:23:12 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US