Home » SQL & PL/SQL » SQL & PL/SQL » uninitialized composite (oracle 9i-pl/sql)
uninitialized composite [message #381859] Tue, 20 January 2009 02:37 Go to next message
nicky
Messages: 5
Registered: January 2009
Junior Member
Good day.
I am having a small problem when running the below code.
I get an error ORA-06530: Reference to uninitialized composite.
Can someone please check over my code and advise on what I am doing wrong. Any help would be greatly appreciated.
Thanks.

create or replace package body pkg_abc_test is

/*ABC_ARRAY declared as varray(10) of ABC_OBJECT
  ABC_OBJECT declared as object(number, varchar2(20), varchar2(20))
*/

  
function get_my_array return ABC_ARRAY is
         
         my_arr ABC_ARRAY;
         my_obj ABC_OBJ;
         var_i number; 
         cursor my_cur is select e.entity_no, e.surname, e.firstname from entities e;
   begin    
            --null;
        var_i:=0;
        for r_my_cur in my_cur loop 
            
            while(var_i<10) loop
            
                 my_obj.entity_num:=r_my_cur.entity_no;
                 my_obj.l_name:=r_my_cur.surname;
                 my_obj.f_name:=r_my_cur.firstname;
            
                 var_i:=var_i+1;
            end loop;
            
            my_arr(var_i):=my_obj;
            
        end loop;
   
         
   exception
     when no_data_found then
        begin
          null;
        end;
        return my_arr;
   end;                             
                                  
end pkg_abc_test;
Re: uninitialized composite [message #381865 is a reply to message #381859] Tue, 20 January 2009 02:46 Go to previous message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
ORA-06530: Reference to uninitialized composite
 *Cause:  An object, LOB, or other composite was referenced as a
          left hand side without having been initialized.
 *Action: Initialize the composite with an appropriate constructor
          or whole-object assignment.

Initialize your collection:
my_arr ABC_ARRAY := ABC_ARRAY();

Regards
Michel

Previous Topic: PL/SQL loops
Next Topic: drop/create table in procedure
Goto Forum:
  


Current Time: Mon Dec 05 15:17:20 CST 2016

Total time taken to generate the page: 0.17152 seconds