【问题标题】:Abstract data type in Oracle 11g ORA-00904: invalid identifierOracle 11g ORA-00904 中的抽象数据类型:标识符无效
【发布时间】: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": 标识符无效

如何解决错误?

谢谢

【问题讨论】:

    标签: sql oracle ora-00904


    【解决方案1】:

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

    select c.person.FullName from customer c;
    

    SQL Fiddle.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多