0

Oracle 版本: Oracle Database 11g Express Edition Release 11.2.0.2.0- 生产

    create type address_ty as object
    (street varchar2(50),
     city varchar2(50),
     state varchar2(25),
     postalcode integer);

    create or replace type person_ty as object
    (FullName varchar2(50),
     BirthDate date,
     Address address_ty,
     member function CalcAge (BirthDate in DATE) return number,
     PRAGMA RESTRICT_REFERENCES (CALCAGE, WNDS));

    create or replace type body person_ty as 
    member function CalcAge (BirthDate DATE) return number is
    begin
       return round(sysdate - BirthDate);
    end;
    end;
    /

    create table customer (customerId integer,
                       Person person_ty);

    describe customer;

    select attr_name, length, attr_type_name from user_type_attrs where type_name = 'PERSON_TY';

    select attr_name, length, attr_type_name from user_type_attrs where type_name = 'ADDRESS_TY';

    insert into customer values (1, person_ty('ABC', '01-JAN-95', address_ty('MG Road', 'Bangalore', 'KA', 560001)));

    select person.FullName from customer;

上述语句显示错误 -

ORA-00904: "PERSON"."FULLNAME": 无效标识符

如何解决错误?

谢谢

4

1 回答 1

0

我相信你需要用表来限定列,所以它不会试图解释person为表名;它必须是别名(不完全确定为什么):

select c.person.FullName from customer c;

SQL 小提琴

于 2013-10-12T11:06:10.990 回答