错误声明不完整或格式错误

时间:2013-12-20 17:42:52

标签: sql oracle function types

我有错误 - 来自最后一个类型 - “Subscriber_T”的......的声明不完整或格式错误,但我没有看到语法问题。这些是脚本:

CREATE OR REPLACE TYPE Surnames_T AS OBJECT (
  Surname varchar (20)
);
/

CREATE OR REPLACE TYPE listSurnames_T 
AS Varray(4) of Surnames_T;
/


CREATE OR REPLACE TYPE listTels as object(
  Tel   number (12)
);
/

CREATE OR REPLACE TYPE listTels_T as Varray(5) of listTels;
/


CREATE OR REPLACE TYPE ADDRESS_T AS OBJECT (
  NUM       number (6),
  STREET    varchar (20),
  TOWN      varchar (20)
);
/

CREATE or replace type TAddress 
as table of Address_T;
/

create or replace type Subscriber_T as object(
  num_s  number(6),
  sName varchar(30), 
  surname listSurnames_T,
  Adds TAddress,
  DateOfBirth  date,
  member function cal_Age return number,
  phoneNo   listTels_T
);
/
show error

我需要修复一下!

1 个答案:

答案 0 :(得分:2)

您必须在所有其他字段之后放置成员函数;你最后不能潜入一个领域:

create or replace type Subscriber_T as object(
  num_s  number(6),
  sName varchar(30), 
  surname listSurnames_T,
  Adds TAddress,
  DateOfBirth  date,
  phoneNo   listTels_T,
  member function cal_Age return number
);
/

TYPE SUBSCRIBER_T compiled

强制性SQL Fiddle

这显示在the syntax diagram in the documentation;你可以拥有一个或多个属性,然后是一个或多个元素(包括函数),但你不能将它们混合在一起。注意哪些位有循环,以及循环返回的位置。