Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Techniques for selecting an object's attribute

User_1871May 16 2022

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 .

This post has been answered by BluShadow on May 16 2022
Jump to Answer

Comments

Processing

Post Details

Added on May 16 2022
3 comments
387 views