How to init an object type

I have the following code :

CREATE OR REPLACE TYPE ObjB IS OBJECT (
B1 varchar2(10)
,B2 varchar2(10)
);

CREATE OR REPLACE TYPE ObjC IS OBJECT (
C1 varchar2(10)
,C2 varchar2(10)
);

CREATE OR REPLACE TYPE ObjCArr IS VARRAY(100) OF ObjC;

CREATE OR REPLACE TYPE ObjA IS OBJECT (
A1 varchar2(10)
,A2 varchar2(10)
,Ab ObjB
,Ac ObjCArr
);

a ObjA;

I've tried to initialize a, but each time I have an ORA-06530 error.

Any idea how to initialize it using Oracle 8.1.7 ?

Nusa

If you want to initialize, use:

DECLARE a ObjA := ObjA(NULL,NULL,ObjB(NULL,NULL),ObjCArr());

Note: Since element a.Ac is a VARRAY of objects ObjC, you would have to use

a.Ac.EXTEND;
a.Ac(1) := ObjC('X','Y');

to add elements to VARRAY. You can not add it using:

a.Ac.EXTEND;
a.Ac(1).C1 := 'X';
a.Ac(2).C2 := 'Y';

You can use already existing a.Ac(1).C1 or a.Ac(1).C2 for existing elements only.

Solomon Yakobson

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.