Problem with the varray...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NewToOracle
    New Member
    • Feb 2009
    • 15

    Problem with the varray...

    Hi.

    Here is the code I tried for the use of the varray..I am trying to dump the values into the array using for loop.. But it's giving the error "error : Trying to access uninitialized object"

    The reason I got.. because I am trying to access temp_array(0) before initializing it.But I want to put the elements dynamically into the database.

    declare type array_var is varray(10) of number(10,2);
    tem_array array_var;
    begin
    for i IN 0..9 loop
    tem_array(i) := i+1;
    end loop;
    end;

    Can anybody help me How can I achieve the functionality ..?

    Thanks!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try using the following code

    Code:
    declare 
    type array_var is varray(10) of number(10,2);
    tem_array array_var;
    begin
    for i IN 1..10 loop
    tem_array(i) := i+1;
    end loop;
    end;

    Comment

    • Saii
      Recognized Expert New Member
      • Apr 2007
      • 145

      #3
      declare
      type array_var is varray(10) of number(10,2);
      tem_array array_var :=array_var();
      begin
      for i IN 1..10 loop
      tem_array.exten d;
      tem_array(i) := i+1;
      end loop;
      end;

      Comment

      Working...