2013-12-20 51 views
1

我有錯誤 - 聲明...不完整或來自最後一個類型「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 

我需要修復請!

回答

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;你可以有一個或多個屬性,然後有一個或多個元素(包括函數),但是你不能混合它們。注意哪些位有循環,以及它們循環到哪裏。

+0

謝謝Alex!該類型現在編譯成功,但在創建Subscriber_T類型的表後,我遇到了新問題。我剛剛發佈了一個新問題,其中包含此表以及函數和插入值。請幫忙。 TNX –