Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-29 · container image gvenzl/oracle-free:23-slim
A variable of an object type (CREATE TYPE … AS OBJECT) starts as NULL. Not "an object with NULL attributes", but no object at all. Writing a.city := … to it fails with ORA-06530, and ORA-06512 shows the line.
The fix is to create the object first with its constructor, for example addr_t(NULL, NULL), then set attributes. The same applies to each element of a nested table of objects. Both cases below were run on Oracle 26ai Free.
01Object type variable declared but not constructed
With addr_t AS OBJECT (city, zip), the block declares a addr_t; and then runs a.city := 'Seoul'. It fails with ORA-06530 at line 4, the assignment line.
USER_TYPES shows ADDR_T is an OBJECT with 2 attributes, so the constructor needs 2 arguments. Declaring a addr_t := addr_t(NULL, NULL); made the same block print Seoul.
Setup
CREATE TYPE addr_t AS OBJECT (city VARCHAR2(20), zip VARCHAR2(10));
/Type created.SET SERVEROUTPUT ON
DECLARE
a addr_t;
BEGIN
a.city := 'Seoul';
DBMS_OUTPUT.PUT_LINE(a.city);
END;
/DECLARE
*
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at line 4
Help: https://docs.oracle.com/error-help/db/ora-06530/COLUMN type_name FORMAT A10
COLUMN typecode FORMAT A12
SELECT type_name, typecode, attributes FROM user_types WHERE type_name = 'ADDR_T';TYPE_NAME TYPECODE ATTRIBUTES
---------- ------------ ----------
ADDR_T OBJECT 2
1 row selected.The constructor takes one argument per attribute, in declaration order. Passing NULL is fine.
SET SERVEROUTPUT ON
DECLARE
a addr_t := addr_t(NULL, NULL);
BEGIN
a.city := 'Seoul';
DBMS_OUTPUT.PUT_LINE(a.city);
END;
/Seoul
PL/SQL procedure successfully completed.02Collection element of an object type left NULL after EXTEND
Here addr_tab is a nested table of addr_t. The collection itself is initialized with addr_tab(), and v.EXTEND adds one element, but that element is still NULL. v(1).city := 'Busan' fails with ORA-06530 at line 5.
Assigning an object to the element first, v(1) := addr_t(NULL, NULL);, then setting v(1).city worked and printed Busan.
Setup
CREATE TYPE addr_t AS OBJECT (city VARCHAR2(20), zip VARCHAR2(10));
/
CREATE TYPE addr_tab AS TABLE OF addr_t;
/Type created.
Type created.SET SERVEROUTPUT ON
DECLARE
v addr_tab := addr_tab();
BEGIN
v.EXTEND;
v(1).city := 'Busan';
DBMS_OUTPUT.PUT_LINE(v(1).city);
END;
/DECLARE
*
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at line 5
Help: https://docs.oracle.com/error-help/db/ora-06530/COLUMN type_name FORMAT A10
COLUMN typecode FORMAT A12
SELECT type_name, typecode FROM user_types ORDER BY type_name;TYPE_NAME TYPECODE
---------- ------------
ADDR_T OBJECT
ADDR_TAB COLLECTION
2 rows selected.Initializing the collection and initializing each object element are separate steps.
SET SERVEROUTPUT ON
DECLARE
v addr_tab := addr_tab();
BEGIN
v.EXTEND;
v(1) := addr_t(NULL, NULL);
v(1).city := 'Busan';
DBMS_OUTPUT.PUT_LINE(v(1).city);
END;
/Busan
PL/SQL procedure successfully completed.FAQ
What does "Reference to uninitialized composite" mean?
The object variable or collection element is NULL as a whole, so it has no attributes to set. Create it with the type constructor, like addr_t(NULL, NULL), before assigning attributes.
I called EXTEND, why do I still get ORA-06530?
EXTEND adds a NULL element. For a collection of objects you must also assign an object to the element, for example v(1) := addr_t(NULL, NULL);.
How many arguments does the object constructor need?
One per attribute. SELECT type_name, attributes FROM user_types shows the count; addr_t on this page had 2.
Which line caused ORA-06530?
Look at the ORA-06512: at line N that follows it. On this page it pointed to the line that set the attribute.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0