Oracle 11g ORA-00904 中的抽象数据类型:标识符无效

Posted

技术标签:

【中文标题】Oracle 11g ORA-00904 中的抽象数据类型:标识符无效【英文标题】:Abstract data type in Oracle 11g ORA-00904: invalid identifier 【发布时间】:2013-10-12 10:02:19 【问题描述】:

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": 标识符无效

如何解决错误?

谢谢

【问题讨论】:

【参考方案1】:

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

select c.person.FullName from customer c;

SQL Fiddle.

【讨论】:

以上是关于Oracle 11g ORA-00904 中的抽象数据类型:标识符无效的主要内容,如果未能解决你的问题,请参考以下文章

ORA-00904: "INSURER_NO": 无效标识符

带有错误 ORA-00904 的 Oracle 更新语句

创建带有外键的表会出现错误 ORA-00904: : oracle 10g 中的无效标识符 [重复]

Oracle DB - ORA-00904:选择时出现“无效标识符”错误

ORACLE ORA-00904: 无效标识符错误

为啥我会收到:[Oracle][ODBC][Ora]ORA-00904:标识符无效