Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> how to update an inherited subtype object's attributes in oracle 9i

how to update an inherited subtype object's attributes in oracle 9i

From: Bo Wang <andrew_wb_at_hotmail.com>
Date: 1 Jun 2003 10:25:03 -0700
Message-ID: <3026d34.0306010925.24629943@posting.google.com>


hi, there:

    I have two tables, UNIT_TAB and PERSON_TAB, unit_tab will keep all the information of university, department and faculty, university_t, department_t and faculty_t are subtype of unit_t; person_tab will store all the info about president, professor and staff, and president_t, professor_t and staff_t are subtype of person_t.

    when I try to populate the database, I find I need to update the attributes of the objects of the subtype, but I cannot find a way to update them, since all the attributes seem to be hidden from the supertype object. I paste part of the codes I have now, hopefully someone can give me a clue how to update it. for example, if I want to update the unit_v() or person_v() of unit_tab, which command can do this.

    BTW, when I use select * from unit_tab, I could only see the attributes of supertype, is a way I can see all the attibutes of the subtype, so i can check if I have succefully inserted all the infomations.

thanks a lot!

Bo


drop table UNIT_TAB;
drop table PERSON_TAB;  

drop type person_t force;
drop type person_v force;
drop type president_t force;
drop type staff_t force;
drop type professor_t force;

drop type unit_t force;
drop type unit_v force;
drop type department_t force;
drop type faculty_t force;
drop type university_t force;

create type person_t as object (

        name varchar2(30)
) not final
/

create or replace type unit_t as object (

        name varchar2(30)
) not final
/

create type person_v as varray(40) of ref person_t
/

create type unit_v as varray(40) of ref unit_t
/

create type university_t under unit_t (

	sub_units unit_v,
	president ref person_t,
	univ_staffs  person_v	

)
/

create type faculty_t under unit_t (

	faculty_univ ref unit_t,
	faculty_depts unit_v,
	faculty_profs person_v,
	faculty_staffs person_v

)
/

create type department_t under unit_t (

	dept_unit ref unit_t,
	dept_profs person_v,

   dept_staffs person_v
)
/

create type president_t under person_t(

	title varchar2(30),
	university ref unit_t

)
/

create type staff_t under person_t(

	staff_rank varchar2(30),
	staff_unit ref unit_t

)
/

create type professor_t under person_t(

	research varchar2(30),
	prof_unit ref unit_t

)
/

create table UNIT_TAB of unit_t;
--nested table unit_nt store as unit_nt_tab --nested table person_nt store as person_nt_tab;

create table PERSON_TAB of person_t;
--nested table unit_nt store as unit_nt_tab --nested table person_nt store as person_nt_tab;

insert into unit_tab values( university_t('Queens University', unit_v(), null, person_v() ) );
--insert into unit_tab values( unit_t('Queens University') );

insert into person_tab values( president_t('Edward', 'President',

        ( select ref(u) from unit_tab u where u.name='Queens University' ) ) );

--update unit_tab
--set values = ( university_t('Queens University', unit_v(), (select ref(p) from person_tab where p.name='Edward' ), person() )) --where name = 'Queens University';

select * from unit_tab;

select * from person_tab; Received on Sun Jun 01 2003 - 12:25:03 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US