Forum Stats

  • 3,837,046 Users
  • 2,262,222 Discussions
  • 7,900,189 Comments

Discussions

Techniques for selecting an object's attribute

User_1871
User_1871 Member Posts: 244 Red Ribbon

I have a column that is an object datatype — SDO_GEOMETRY:

create table my_tbl (shape sdo_geometry);
insert into my_tbl (shape) values (sdo_geometry('LINESTRING(1 2,3 4)'));

The object has attributes (2.2 SDO_GEOMETRY Object Type):

SDO_GTYPE
SDO_SRID
SDO_POINT
SDO_ELEM_INFO
SDO_ORDINATES

I want to select an attribute from the object. I can do that by using a table alias:

select
  a.shape.sdo_gtype
from
  my_tbl a

Out of curiosity, are there any other ways to select object attributes, other than creating an alias?

As a non-expert, it seems strange to me that the alias is necessary. Of course, creating an alias isn't a big deal, but I would have guessed that I could just use the dot notation without an alias: select shape.sdo_gtype from my_tbl. But that doesn't work: ORA-00904: "SHAPE"."SDO_GTYPE": invalid identifier .

Tagged:

Best Answer

Answers