Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to create mutually referencing types ?
A copy of this was sent to may_at_informatik.uni-freiburg.de (Wolfgang May)
(if that email address didn't require changing)
On 14 Dec 1998 12:54:19 GMT, you wrote:
>Hi,
>
>how can I create mutually referencing types ?
>
>e.g., cities which belong to a country, and on the other hand, the
>country has a capital city:
>
>CREATE OR REPLACE TYPE City_Type AS OBJECT
> (Name VARCHAR2(35),
> Country REF Country_Type,
> Population NUMBER,
> Coordinates GeoCoord);
>/
>
>CREATE OR REPLACE TYPE Country_Type AS OBJECT
>(Name VARCHAR2(32),
> Code VARCHAR2(4),
> Capital REF City_Type;
> Area NUMBER,
> Population NUMBER);
>/
>
You can do this by forward declaring the type as follows:
create type Country_type
/
CREATE OR REPLACE TYPE City_Type AS OBJECT
(Name VARCHAR2(35),
Country REF Country_Type,
Population NUMBER );
/
CREATE OR REPLACE TYPE Country_Type AS OBJECT
(Name VARCHAR2(32),
Code VARCHAR2(4),
Capital REF City_Type,
Area NUMBER,
Population NUMBER);
/
>??
>
>First defining country_type without the capital attribut, then
>defining city_type, and then altering country_type by adding the
>reference to city does not work since my oracle complains that
>attributes acnnot be altered by ALTER TYPE:
>
>ALTER TYPE Country_Type REPLACE AS OBJECT
> (Capital REF City_Type);
>
>FEHLER in Zeile 1:
>ORA-22319: Typattributinformationen in ALTER TYPE geaendert
>[engl: Type attribute information changed in ALTER TYPE]
>
>Wolfgang
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA
--
http://govt.us.oracle.com/ -- downloadable utilities
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Dec 14 1998 - 07:51:06 CST