0

I had created two object types and tables based on that types in oracle:

create or replace type TEMPLOYE as object(
num_emp integer,
nom_emp varchar2(40),
prenom_emp varchar2(50),
adresse_emp varchar2(200),
tel_emp varchar2(15)
) not final;
/
create or replace type TMEDECIN under TEmploye (
num_med integer,
specialite Varchar2(30)
);
/
CREATE TABLE EMPLOYEES OF TEMPLOYE;
CREATE TABLE MEDECINS OF TMEDECIN;

and I had inserted some values into EMPLOYEES like :

INSERT INTO EMPLOYEES VALUES (
TEMPLOYE (10,'BOUCHEMLA','Elias','6, hai sidi serhane -Khemis El Khechna-Boumerdes',024873549)); 

Finally I need to insert a record into MEDECINS table with num_med=10 and specialite='Cardiologue' and the others attributes from the parent table (EMPLOYEES), how to do that using select * statement or a reference?

1

Simply INSERT ... SELECT.

insert into
  medecins
select
  e.*,
  10,
  'Cardiologue'
from
  employees e
where
  e.num_emp = 10
;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.