我试图使用Subtype对象代替Supertype对象,但它不工作?

时间:2014-04-16 06:45:05

标签: oracle plsql oracle11g

我创建了两个对象T_PERSONS,T_BUSINESS_PERSON,其中T_BUSINESS PERSON是一个子类型,T_PERSONS是一个超类型。

---创建T_PERSONS OBJECT ---

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 OBJECT ---

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.

请帮助。

1 个答案:

答案 0 :(得分:0)

第二次插入仅在您按如下方式创建表时才有效:

CREATE TABLE object_customers OF t_business_person;

点击此处阅读有关NOTFINAL 条款的更多信息。