Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-06530: Reference to uninitialized composite

MilleniumaireJun 1 2016 — edited Jun 1 2016

Apologies as I'm aware this error has been raised before, however, after a couple of hours surfing and trying to find the reason I'm getting this error, I have been unable to resolve it for my particular case.

I've constructed a simplified example of my code, which basically involves declaring an object table, which contains a nested object table.  These represent headers and details, where each header will have one or more details.  As I'm new to objects, I'm simply trying to initialise these objects in the code and will later be using the initialised object to call a package procedure that will operate on the data.

Here's my simplified code:

create or replace TYPE DETAIL_OBJ_TYPE AS OBJECT

(

    fact_name          VARCHAR2(100),

    fact_type          VARCHAR2(20),

    fact_value         VARCHAR2(100)  

);

create or replace TYPE DETAILS_DATA_TBL AS TABLE OF DETAIL_OBJ_TYPE;

create or replace TYPE HEADER_OBJ_TYPE AS OBJECT

(

    data_set_name      VARCHAR2(50),

    effective_date     DATE,  

    distinct_data      VARCHAR2(1),

    indexed_value_list DETAILS_DATA_TBL

);

create or replace TYPE HEADERS_DATA_TBL AS TABLE OF HEADER_OBJ_TYPE;

declare   

  lo_headers_tbl HEADERS_DATA_TBL;

begin

  -- Initialise the object table

  lo_headers_tbl := HEADERS_DATA_TBL();

  -- Populate first header

  lo_headers_tbl.EXTEND;

  lo_headers_tbl(1).data_set_name := 'PRINT';             <-- Error reports this line

  lo_headers_tbl(1).effective_date := '20-MAY-16';

  lo_headers_tbl(1).distinct_data := 'Y';

  -- Populate details for first header   

  lo_headers_tbl(1).indexed_value_list.EXTEND;

  lo_headers_tbl(1).indexed_value_list(1) := DETAIL_OBJ_TYPE ('INDEXED_FACT_1','VARCHAR2','SB');

             

  lo_headers_tbl(1).indexed_value_list.EXTEND;

  lo_headers_tbl(1).indexed_value_list(2) := DETAIL_OBJ_TYPE ('INDEXED_FACT_2','VARCHAR2','DS');

             

  lo_headers_tbl(1).indexed_value_list.EXTEND;

  lo_headers_tbl(1).indexed_value_list(3) := DETAIL_OBJ_TYPE ('INDEXED_FACT_4','NUMBER','1');

             

  lo_headers_tbl(1).indexed_value_list.EXTEND;

  lo_headers_tbl(1).indexed_value_list(4) := DETAIL_OBJ_TYPE ('INDEXED_FACT_7','DATE','23-MAY-2016');

  -- Populate second header

  lo_headers_tbl.EXTEND;

  lo_headers_tbl(2).data_set_name := 'SCREEN';

  lo_headers_tbl(2).effective_date := '28-MAY-16';

  lo_headers_tbl(2).distinct_data := 'Y';

   

  -- Populate details for second header   

  lo_headers_tbl(2).indexed_value_list.EXTEND;

  lo_headers_tbl(2).indexed_value_list(1) := DETAIL_OBJ_TYPE ('INDEXED_FACT_1','VARCHAR2','AER02');

             

  lo_headers_tbl(2).indexed_value_list.EXTEND;

  lo_headers_tbl(2).indexed_value_list(2) := DETAIL_OBJ_TYPE ('INDEXED_FACT_3','NUMBER','10');

             

  lo_headers_tbl(2).indexed_value_list.EXTEND;

  lo_headers_tbl(2).indexed_value_list(3) := DETAIL_OBJ_TYPE ('INDEXED_FACT_6','DATE','26-MAY-2016');

 

end;

When the above anonymous PL/SQL block is run, it gives the following error:

ORA-06530: Reference to uninitialized composite

ORA-06512: at line 10

I assume this relates to the initialisation of the lo_headers_tbl, but as you can see at line 6, this has already been initialised.

I would appreciate any pointers as to what I'm doing wrong.  Thanks.

This post has been answered by RogerT on Jun 1 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 29 2016
Added on Jun 1 2016
7 comments
5,201 views