Home » SQL & PL/SQL » SQL & PL/SQL » how can i select from subtypes?
how can i select from subtypes? [message #186155] Sun, 06 August 2006 10:41 Go to next message
ginopilotino
Messages: 2
Registered: August 2006
Junior Member
hi, i say you sorry for my bad english.
i've created this structure:

CREATE TYPE T_LOCALE AS OBJECT (
COD_LOCALE NUMBER,
NOME VARCHAR2(32),
GEOMETRIA SDO_GEOMETRY,
INDIRIZZO SDO_GEO_ADDR,
COD_CATENA NUMBER
)
NOT FINAL;
/


CREATE TYPE T_RISTORANTE UNDER T_LOCALE (
CUCINA VARCHAR2(32)
);
/


CREATE TABLE LOCALI OF T_LOCALE
(PRIMARY KEY(COD_LOCALE));


INSERT INTO LOCALI VALUES
(T_RISTORANTE( '1',
'Da Gino',
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3),
SDO_ORDINATE_ARRAY(7,1, 10,5)),
null,
001,
'Pizza'
)
);


if i try to select the names of the restaurants this query works fine:

select l.nome
from locali l
where value(l) IS OF (t_ristorante);

but i don't know how i can select the values of the "cucina" attribute in T_RISTORANTE.
if i try to execute the query:

select *
from locali

the attribute CUCINA does not appear.

please, help me Sad(((
Re: how can i select from subtypes? [message #186160 is a reply to message #186155] Sun, 06 August 2006 11:10 Go to previous messageGo to next message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
Will this work?

SQL> SELECT TREAT(VALUE(l) AS t_ristorante).cucina
  2    FROM locali l;

TREAT(VALUE(L)AST_RISTORANTE).CU
--------------------------------
Pizza
Re: how can i select from subtypes? [message #186168 is a reply to message #186160] Sun, 06 August 2006 13:11 Go to previous message
ginopilotino
Messages: 2
Registered: August 2006
Junior Member
Frank Naude wrote on Sun, 06 August 2006 11:10

Will this work?

SQL> SELECT TREAT(VALUE(l) AS t_ristorante).cucina
  2    FROM locali l;

TREAT(VALUE(L)AST_RISTORANTE).CU
--------------------------------
Pizza



yeeeeeeeessssssssssssss!!!!!!!!!!
thank youuuuuuu!!! Cool
Previous Topic: about pro c/c++
Next Topic: Autoinc field?
Goto Forum:
  


Current Time: Fri Dec 09 14:01:13 CST 2016

Total time taken to generate the page: 0.17139 seconds