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 -> SOLUTION: Creating a view on an object column

SOLUTION: Creating a view on an object column

From: UnixDBA <unixdba_at_aol.com>
Date: 12 Mar 1999 03:23:43 GMT
Message-ID: <19990311222343.12350.00001142@ng38.aol.com>

     desc address_ty
     Name                            Null?    Type
     ------------------------------- -------- ----
     STREET                                   VARCHAR2(50)
     CITY                                     VARCHAR2(25)
     STATE                                    CHAR(2)
     ZIP                                      NUMBER
     

-- create a table with a column object of the new object type
create table test( address address_ty ) storage( initial 1K next 1K pctincrease 0 ) desc test Name Null? Type ------------------------------- -------- ---- ADDRESS ADDRESS_TY
-- place a row into the new table
insert into test values (address_ty('642 Chestnut St.', 'San Francisco', 'CA', 94123)); commit;
-- bad syntax for creating a view on the table
create or replace view test_ov(address) as select address_ty(street,city,state,zip) from test;
-- error caused by flawed attempt at view creation
select address_ty(street,city,state,zip) * ERROR at line 2: ORA-00904: invalid column name
-- proper syntax for view creation
-- on all columns of the underlying table.
-- instead of using the name of the object type,
-- use the name of the column in the underlying table.
create or replace view test_ov(address) as select address from test;
-- proper syntax for view creation
-- on a single column of the underlying table.
-- note that both a column alias
-- and a table alias are required.
create or replace view test_ov(address) as select t.address.street street_alias from test t;
Received on Thu Mar 11 1999 - 21:23:43 CST

Original text of this message

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