Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

ORA-06530 Reference to Uninitialized Composite Tips

Oracle Database Tips by Donald BurlesonMay 30, 2015

Question:  I am getting an ORA-06530 error in my PL/SQL.  The following returns the ORA-06530:

SQL> create or replace type rep_cnts is object (empno number,
  2  cnt   number);
  3  /

Type created.

SQL> create or replace type repcnts is table of rep_cnts;
  2  /

Type created.


 1  create or replace procedure ge_rm(empno_chng number) as
 2  v_rm emp.mgr%type;
 3  type other_reportees is table of emp.mgr%type;
 4  v_other_reportees other_reportees;
 5  reportees_n_counts repcnts;
 6  begin
 7  reportees_n_counts:= repcnts();
 8  select mgr into v_rm from emp where empno=empno_chng;
 9  select empno bulk collect into v_other_reportees from emp where mgr= v_rm and empno <> empno_chng ;
10  for i in 1..v_other_reportees.count loop
11  reportees_n_counts.extend;
12  begin
13  select mgr,count(*) into reportees_n_counts(i).empno,reportees_n_counts(i).cnt from emp  where mgr=v_other_reportees(i) group by mgr;
14  exception
15  when no_data_found then
16  reportees_n_counts(i).empno:=v_other_reportees(i);
17  reportees_n_counts(i).cnt:=0;
18  end;
19  end loop;
20  for j in 1..reportees_n_counts.last loop
21  dbms_output.put_line(reportees_n_counts(j).empno||'-'||reportees_n_counts(j).cnt );
22  end loop;
23* end;

SQL> /

Procedure created.

SQL> exec ge_rm(7499);
BEGIN ge_rm(7499); END;

*
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at "SCOTT.GE_RM", line 16
ORA-01403: no data found
ORA-06512: at line 1

What is the cause of the ORA-06530: Reference to uninitialized composite error?  

Answer: 

The oerr utility shows this for the ORA-06530 error:  

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.  

According to the information you have included, your error is at line 16 of your procedure:

16  reportees_n_counts(i).empno:=v_other_reportees(i);

In this case, after the BEGIN, you need to initialize the object using a constructor.

Another way to avoid the "ORA-06530: Reference to uninitialized composite " is to use the RECORD type declaration:  

1   create or replace procedure ge_rm(empno_chng number) as  
2   v_rm emp.mgr%type;  
3   type other_reportees is table of emp.mgr%type;  
4   v_other_reportees other_reportees;  
5   type rep_cnts is record ( -- NEWLY INCLUDED RECORD DECLARATION
6   empno number,               -- NEWLY INCLUDED RECORD DECLARATION
7   cnt number);                     -- NEWLY INCLUDED RECORD DECLARATION
8   type repcnt  is table  of rep_cnts;  
9   reportees_n_counts repcnt;
10  begin
11  reportees_n_counts:= repcnt();
12  select mgr into v_rm from emp where empno=empno_chng;
13  select empno bulk collect into v_other_reportees from emp where mgr= v_rm and empno <> empno_chng ;
14  for i in 1..v_other_reportees.count loop
15  reportees_n_counts.extend;
16  begin
17  select mgr,count(*) into reportees_n_counts(i).empno,reportees_n_counts(i).cnt from emp  where mgr=v_other_reportees(i) group by mgr;
18  exception
19  when no_data_found then
20  reportees_n_counts(i).empno:=v_other_reportees(i);
21  reportees_n_counts(i).cnt:=0;
22  end;
23  end loop;
24  for j in 1..reportees_n_counts.last loop
25  dbms_output.put_line(reportees_n_counts(j).empno||'-'||reportees_n_counts(j).cnt );
26  end loop;
27* end;

SQL> /

Procedure created.

SQL> exec ge_rm(7499);
7521-0
7566-2
7654-0
7782-1
7844-0

PL/SQL procedure successfully completed.  

 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.


 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster