Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Creating types in Orace 9i: any help?

Re: Creating types in Orace 9i: any help?

From: Roman Zhovtulya <romanlutsk_at_yahoo.com>
Date: Tue, 26 Nov 2002 23:22:03 +0100
Message-ID: <as0s9d$396$1@news.BelWue.DE>


Hello,
Thanks a lot again for the help.
I've tried earlier with "not final" in Toad without success, but now when I started all over again in "SQLPlus", it worked.

Thanks again,
Roman Zhovtulya

"Finn Ellebaek Nielsen" <_remove_fen_remove__at_changegroup.dk> wrote in message news:3de2aa8f$0$167$edfadb0f_at_dread14.news.tele.dk...
> Hi there.
>
> I get PLS-00590: attempting to create a subtype UNDER a FINAL type when
> trying to create the STUDENTTYPE specialization. This is due to the fact
> that you need to specify NOT FINAL for the PERSONTYPE in order to be able
to
> allow specialization/inheritance of the first type (for backward
> compatibility):
>
> SQL> drop type studenttype;
>
> Type dropped.
>
> SQL>
> SQL> create or replace type Persontype as Object (
> 2 PersNr integer,
> 3 Name varchar(30)
> 4 ) not final;
> 5 /
>
> Type created.
>
> SQL> create or replace type Studenttype under Persontype (
> 2 team number
> 3 );
> 4 /
>
> Type created.
>
> SQL> create table test of Studenttype;
>
> Table created.
>
> HTH.
>
> Finn
>
> --
> --------------------------------------------------------------------------
-
> Finn Ellebaek Nielsen ChangeGroup ApS
> Product Manager, Principal Consultant, Partner Kronprinsessegade 54, 4.
> E-mail: finn.ellebaek.nielsen_at_changegroup.dk DK-1306 Koebenhavn K
> Mobile: +45 20 32 49 25 Denmark
> Phone: +45 33 32 77 78 http://www.changegroup.dk
> --------------------------------------------------------------------------
-
> "Where do you want to GPF today?"
> "Roman Zhovtulya" <roman_at_fh-offenburg.de> wrote in message
> news:artktk$d1e$1_at_news.BelWue.DE...
> > Hello,
> > Thank you very much for the help.
> > Now I'm able to create user defined types, but I still cannot figure out
> how
> > to inherit one datatype from another.
> > So, I define a type:
> >
> > > create or replace type Persontype as Object (
> > > PersNr integer,
> > > Name varchar(30)
> > > );
> > > /
> >
> > Then I inherit a new type from the above-defined type:
> >
> > > create or replace type Studenttype under Persontype (
> > > team number
> > > );
> > -- no errors
> >
> > But, when I try to make a table to the inherited "Studenttype":
> >
> > > create table test of Studenttype
> >
> > --it gives an "Invalid datatype" error.
> >
> > Any help would be appreciated.
> >
> > Thanks a lot,
> > Roman Zhovtulya
> >
> >
> > "Finn Ellebaek Nielsen" <_remove_fen_remove__at_changegroup.dk> wrote in
> > message news:3de14d3f$0$214$edfadb0f_at_dread14.news.tele.dk...
> > > Because there's a comma after the second attribute:
> > >
> > > create or replace type Persontype as Object (
> > > PersNr integer,
> > > Name varchar(30),
> > > );
> > > /
> > >
> > > The correct version is
> > >
> > > create or replace type Persontype as Object (
> > > PersNr integer,
> > > Name varchar(30)
> > > );
> > > /
> > >
> > > (you use the comma to separate attributes and methods).
> > >
> > > HTH.
> > >
> > > Finn
> > >
> > > --
> >
>
> --------------------------------------------------------------------------
> > -
> > > Finn Ellebaek Nielsen ChangeGroup ApS
> > > Product Manager, Principal Consultant, Partner Kronprinsessegade 54,
> 4.
> > > E-mail: finn.ellebaek.nielsen_at_changegroup.dk DK-1306 Koebenhavn K
> > > Mobile: +45 20 32 49 25 Denmark
> > > Phone: +45 33 32 77 78
> http://www.changegroup.dk
> >
>
> --------------------------------------------------------------------------
> > -
> > > "Where do you want to GPF today?"
> > > "Roman Zhovtulya" <roman_at_fh-offenburg.de> wrote in message
> > > news:arrcr8$s1l$1_at_news.BelWue.DE...
> > > > Hello Dennis,
> > > > Thanks a lot for the help and explanations.
> > > > I've tried compiling the following:
> > > > -----
> > > > create or replace type Persontype as Object
> > > > (
> > > > PersNr integer,
> > > > Name varchar(30),
> > > > );
> > > > /
> > > > -----
> > > > , but it kept on giving "compiled with errors".
> > > >
> > > > I searched Google and came accross the following line:
> > > > ----
> > > > map member function map_function return varchar2
> > > > ----
> > > > If I add it after "Name varchar(30)", it works flawlessly.
> > > > (i.e,
> > > > ----
> > > > create or replace type Persontype as Object
> > > > (
> > > > PersNr integer,
> > > > Name varchar(30),
> > > > map member function map_function return varchar2
> > > > );
> > > > /
> > > > ----
> > > >
> > > > Any idea of why it's needed there?
> > > >
> > > > Thanks a lot,
> > > > Roman Zhovtulya
> > > >
> > > >
> > > >
> > > > "Dennis Petersen" <fessor_at_software.dk> wrote in message
> > > > news:arqktd$gkk$1_at_news.cybercity.dk...
> > > > > > create type Persontype
> > > > > > (
> > > > > > PersNr integer,
> > > > > > Name varchar(30),
> > > > > > primary key (EmpNr)
> > > > > > );
> > > > >
> > > > > You need to tell that it is of an object type, also use the create
> or
> > > > > replace if you plan to use a script that you can just run again
> every
> > > time
> > > > > you change something...
> > > > > Another thing is that you declare a primary key ? This is not for
> the
> > > > object
> > > > > but could very well be on the table where you want to insert the
> > > object...
> > > > > so try the following:
> > > > >
> > > > > create or replace type Persontype as Object
> > > > > (
> > > > > PersNr integer,
> > > > > Name varchar(30),
> > > > > );
> > > > > -- The / tells Oracle that the definition is done and it should
> > compile
> > > > the
> > > > > object...
> > > > > /
> > > > > -- Now here's a table that can contain the Persontype objects
> > > > > create table people(
> > > > > EmpNr integer,
> > > > > person PersonType,
> > > > > CONSTRAINT pk_people PRIMARY KEY(EmpNr)
> > > > > );
> > > > > -- Note you could easily just declare a table of Persontype type
and
> > > > Oracle
> > > > > will assign an OID (Object ID) as a unique identifier... like this
> > > > > -- create table people of Persontype
> > > > >
> > > > > Hope it helps...
> > > > > Sincerely,
> > > > > Dennis P
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
Received on Tue Nov 26 2002 - 16:22:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US