Seach Makes Easy

Labels:

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.

Comments (0)

Followers

Blog Archive