Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is it possible to define a record as the union of 2 records

declare
     type a is record(a1 number, a2 varchar2(10));
     type b is record(b1 number, b2 varchar2(10));
     type c is record(a1 number, b2 varchar2(10),c1 number, c2 varchar2(10));
begin
    null;
end;

the record c is defined like that: the fields of c are the field of a + b.

I have a real example with a lot of field. Is there a more efficient way to declare c.

Something like that ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 type c is record( a..., c...);

And more importantly I would like thatif I change the definition of a or b, the definition of c change too.
code on dbfiddle

>Solution :

%ROWTYPE only applies to tables.  Just do this:

declare
     type a is record(a1 number, a2 varchar2(10));
     type b is record(b1 number, b2 varchar2(10));
     type c is record(a2 a, b2 b);
begin
    null;
end;

Yes if you change a or b, then c will change

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading