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: Michel Cadot <micadot{at}altern{dot}org>
Date: Sun, 15 Apr 2007 12:05:05 +0200
Message-ID: <4621f8d2$0$21088$426a34cc@news.free.fr>

"Ora_PL" <ploug_at_onet.eu> a écrit dans le message de news: evsslo$k1f$1_at_news.onet.pl...
| Hi All
|
| I'd like to fill up varray table by using dbms_random.(oracle 9.2)
| In this case (look example) I get error ORA-06533 as a result of wrong
| implicit extend method, I suppose.
| But in another case when I'm write explicit Extend like this:
| V_TABLE.Extend(v_in) I have the same problem. So Can I have any
| suggestions?
|
|
| Example:
|
| DECLARE
|
| V_IN NUMBER(2);
| TYPE table_v IS VARRAY(3) OF NUMBER;
| V_TABLE TABLE_v;
|
| BEGIN
|
| v_in := dbms_random.VALUE(1,3);
| v_table := TABLE_v(V_IN);
|
| DBMS_OUTPUT.PUT_LINE(TO_CHAR(V_TABLE(1))||'|'||TO_CHAR(V_TABLE(2))||'|'||TO_CHAR(V_TABLE(3)));
|
| --or
| for idx in v_table.first..v_table.last loop
| DBMS_OUTPUT.PUT_LINE(TO_CHAR(v_Table(idx)));
| end loop;
|
| END;
|
| /

SQL> DECLARE
  2
  3 V_IN NUMBER(2);
  4 TYPE table_v IS VARRAY(3) OF NUMBER;   5 V_TABLE TABLE_v;
  6
  7 BEGIN
  8
  9 v_in := dbms_random.VALUE(1,3);
 10 v_table := TABLE_v(V_IN);
 11
 12 for idx in v_table.first..v_table.last loop  13 DBMS_OUTPUT.PUT_LINE(TO_CHAR(v_Table(idx)));  14 end loop;
 15
 16 END;
 17 /
1

PL/SQL procedure successfully completed.

SQL> /
2

PL/SQL procedure successfully completed.

SQL> /
1

PL/SQL procedure successfully completed.

SQL> /
3

PL/SQL procedure successfully completed.

SQL> @v

Version Oracle : 9.2.0.8.0

Regards
Michel Cadot Received on Sun Apr 15 2007 - 05:05:05 CDT

Original text of this message

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