Inserting values in the object type: CREATE TYPE external_person AS OBJECT ( nam
ID: 3705598 • Letter: I
Question
Inserting values in the object type: CREATE TYPE external_person AS OBJECT ( name VARCHAR2(30), phone VARCHAR2(20) ); CREATE TABLE contacts ( contact external_person udate DATE ); INSERT INTO contacts VALUES ( external_person (NULL, NULL), '24-Jun -97' ); (1) Create user-defined types as follows: CREATE TYPE location as OBJECT( building_no NUMBER, city VARCHAR2(40) ); CREATE TYPE person as OBJECT( ssno NUMBER, name VARCHAR2(100), address VARCHAR2(100), office location ); CREATE TABLE persons of person; Insert a row into the persons table.
Explanation / Answer
Below is the insert statement:
INSERT INTO persons VALUES ( person(1,'DAVE','CA', location(15,'CALIFORNIA')) );
Explanation:
Here we create a type loxcation and after that another nested type person. Then we create a table persons refering to person. Thus while inserting the data to persons table we have followed the same order.
Sample output:
1 row(s) inserted.