Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Creating types in Orace 9i: any help?
Hello Dennis,
Thanks a lot for the help and explanations.
I've tried compiling the following:
PersNr integer,
Name varchar(30),
);
/
I searched Google and came accross the following line:
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 theobject
> 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 compilethe
> 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 andOracle
> 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 Sun Nov 24 2002 - 14:30:42 CST