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

Home -> Community -> Usenet -> c.d.o.server -> Re: QUESTION: can you create a new datatype and setting/getting there values

Re: QUESTION: can you create a new datatype and setting/getting there values

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: 10 Oct 2003 17:26:37 GMT
Message-ID: <bm6q4d$jqg7v$2@ID-82536.news.uni-berlin.de>

> Hi, in Oracle you can go
>
> create table testtable(a number,b number);
> insert into testtable values(1,0);
> insert into testtable values(33,1);
> insert into testtable values(1,16);
> select * from testtable where a=1;
>
> Question
> ***********
> Can I create my own datatype in Oracle, called for example BNO, and
> insert into and select from this new datatype using a similar syntax
> so that the syntax to use BNO is the same type of syntax to use for
> number, varchar2, etc.
>
> Like
>
> create table testtable(a number, b BNO);
> insert into testtable values (1,0);
>
> Here BNO is a 'number', but I want my object to have a default
> 'constructor' or 'setter' that accepts a number, and if none exists
> then get an error. To select from the table, I want a default 'getter'
> ... etc
>
> If you can do this type of thing can someone please post some keywords
> to search on and I will try to find the information from there?
> Thank you
> Barry

create or replace type bno as object (
  a_ number
);
/

create table testtable (a number, b bno);

insert into testtable values(1, bno(2));
insert into testtable values(4, bno(3));
insert into testtable values(8, bno(4));

commit;

select * from testtable;

hth
Rene

-- 
  Rene Nyffenegger
  http://www.adp-gmbh.ch
Received on Fri Oct 10 2003 - 12:26:37 CDT

Original text of this message

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