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 -> Re: dbms_random&varray

Re: dbms_random&varray

From: Ora_PL <ploug_at_onet.eu>
Date: Sun, 15 Apr 2007 15:18:07 +0200
Message-ID: <evt8m9$ink$1@news.onet.pl>


Maxim Demenko:

> Why should one use this method? Only to prove himself, that if a varray
> is initialized with only *one* element
> (v_table := TABLE_v(V_IN);)
> any attempt to access this varray by subscripts greater than number of
> elements (i.e, 2 is greater than 1, 3 is greater than 1)
> (DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_TABLE(1))||'|'||TO_CHAR(V_TABLE(2))||'|'||TO_CHAR(V_TABLE(3)));
> )
> will unavoidable result in ORA-06533 ?
> ( well, maybe you suppose, VARRAY(3) automagically initialize varray
> with 3 empty slots - in that case this is wrong assumption)
>
> Best regards
>
> Maxim

Thanks a lot for support, but especially for MAXIM, you are right! Oracle9i Enterprise Edition Release 9.2.0.1.0

DECLARE

V_IN  binary_integer;
V_IN2 binary_integer;
V_IN3 binary_integer;

TYPE table_v IS VARRAY(3) OF binary_integer; V_TABLE TABLE_v;

BEGIN

v_in := trunc(dbms_random.VALUE(1,3));
v_in2 := trunc(dbms_random.VALUE(1,3));
v_in3 := trunc(dbms_random.VALUE(1,3));

v_table := TABLE_v(V_IN,v_in2,v_in3);

DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_TABLE(1))||'|'||TO_CHAR(V_TABLE(2))||'|'||TO_CHAR(V_TABLE(3))); END; /

1|1|2
PL/SQL procedure successfully completed. Received on Sun Apr 15 2007 - 08:18:07 CDT

Original text of this message

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