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: how to reference an item in a user defined type in a column in 24 hours?

Re: how to reference an item in a user defined type in a column in 24 hours?

From: Jusung Yang <JusungYang_at_yahoo.com>
Date: 26 Mar 2003 00:06:26 -0800
Message-ID: <130ba93a.0303260006.5136bda7@posting.google.com>


Table alias is needed in this case. A couple of examples:

SQL> create or replace type Time_Range as Object(   2 start_date date,
  3 end_date date,
  4 repitition_mode int);
  5 /

Type created.

SQL> create table schedule of time_range;

Table created.

SQL> desc schedule

 Name                                      Null?    Type
 ----------------------------------------- --------
----------------------------
 START_DATE                                         DATE
 END_DATE                                           DATE
 REPITITION_MODE                                    NUMBER(38)

SQL> insert into schedule
values(time_range('01-jan-2001','01-jan-2002',1));

1 row created.

SQL> commit;

Commit complete.

SQL> select start_date from schedule;

START_DAT



01-JAN-01 SQL> select p.start_date from schedule p;

START_DAT



01-JAN-01 SQL> drop table schedule;

Table dropped.

SQL> create table schedule (c1 number, c2 time_range);

Table created.

SQL> insert into schedule
values(1,time_range('01-jan-2001','01-jan-2002',100));

1 row created.

SQL> insert into schedule
values(1,time_range('02-jan-2001','02-jan-2002',200));

1 row created.

SQL>
SQL> commit;

Commit complete.

SQL> select p.c2.start_date from schedule p;

C2.START_



01-JAN-01
02-JAN-01 SQL> select p.c2.start_date pdate from schedule p where p.c2.start_date > '01-jan-2001';

PDATE



02-JAN-01

saloan2003_at_yahoo.com (Marwan) wrote in message news:<abee49d2.0303251457.25b65796_at_posting.google.com>...
> Hi all...
>
> Let me try to explain...
>
> I have a datatype defined: Time_Range
> as follows:
> create or replace type Time_Range as Object
> {
> start_date date,
> end_date date,
> repitition_mode int
> };
> /
>
> Now I have a table that has a column of type TimeRange..
> as follows:
> table schedule
> {
> ...
> range time_range,
> ...
> }
>
>
> if want to do something along the lines of select * from schedule
> where range.start_date > .... and range.end_date < ....
>
> but when I try that it says that range.start_date is not a valid
> column name.
>
> How can I reference the parts of the Time_Range structure?
>
>
> Thanks
Received on Wed Mar 26 2003 - 02:06:26 CST

Original text of this message

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