2014-04-16 28 views
0

我創建了兩個對象T_PERSONS,T_BUSINESS_PERSON,其中T_BUSINESS PERSON是子類型,T_PERSONS是超類型。我想用一個子類型對象代替一個超類型對象,但它不工作?

---創建T_PERSONS對象---

CREATE OR REPLACE 
TYPE T_PERSONS AS OBJECT 
(id integer, 
first_name varchar2(10), 
last_name varchar2(10), 
dob DATE, 
phone varchar2(12), 
address t_address, 
) NOT FINAL; 

---創建T_BUSINESS_PERSON對象---

CREATE TYPE t_business_person UNDER t_persons 
(title varchar2(20), 
company varchar2(20) 
); 

現在我創建了一個對象表object_customers

CREATE TABLE object_customers OF t_persons 

將數據插入object_customers

INSERT INTO object_customers VALUES 
(t_persons(1,'Jason','Bond','03-APR-1955','800-555-1211', 
    t_address('21 New Street','Anytown','CA','12345') 
)); 
在這種情況下

,數據已經插入正確

INSERT INTO object_customers VALUES 
(t_business_person(2,'Steve','Edwards','03-MAR-1955','800-555-1212', 
    t_address('1 Market Street','Anytown','VA','12345'),'Manager','XYZ Corp' 
)); 

現在,在這種情況下,即有錯誤

Error-attribute or element value is larger than specified in type. 

請幫助。

回答

0

第二插入方法僅當您創建表如下:

CREATE TABLE object_customers OF t_business_person; 

點擊這裏閱讀更多關於NOTFINAL條款。

+0

我找到了解決方案... anywayz非常感謝。 – Nikhil

相關問題