Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Object Relational Feature of Oracle 8i
Hello Tapas,
As for your first question (what is gained by defining the type before creating the table): I think you named one of the largest benefits when you said you can create the type once and then reference it many times. Other than that, maybe Oracle was just following the standard object-oriented approach of having creating the class definition before instantiating it.
As for your second question, here is a little script to illustrate the basic use of these object tables:
<snip>
create or replace type t_cust_obj
as object (cust_id number, cust_name varchar2(30)) /
create table sales_cust (salesperson_id number, cust t_cust_obj); insert into sales_cust values (1, t_cust_obj(1000, 'Customer 1000')); </snip>
Notice that you can use the type name (t_cust_obj) as a "constructor" to insert values into the column. Here are a couple of sample SELECT statements with their output:
select * from sales_cust;
SALESPERSON_ID CUST(CUST_ID, CUST_NAME)
-------------- ----------------------------------------- 1 T_CUST_OBJ(1000, 'Customer 1000')
select salesperson_id, sc.cust.cust_id as cust_id, sc.cust.cust_name as
cust_name
from sales_cust sc;
SALESPERSON_ID CUST_ID CUST_NAME
-------------- ---------- ------------------------------ 1 1000 Customer 1000
I hope this is enough to get you started.
Chris
"Tapas Guha" <tguha_at_sympatico.ca> wrote in message
news:oX5_7.2954$p04.569383_at_news20.bellglobal.com...
> Recently I took the opportunity to explore the Oracle 8i User Defined
> Datatype and object relational Database Feature.
>
> But at this point, I am little confuse, so please help me to understand
this
> feature.
>
>
>
>
> Salesperson_id Number
> Customer cust_obj
>
>
>