Forum Stats

  • 3,875,133 Users
  • 2,266,809 Discussions
  • 7,912,089 Comments

Discussions

Enhance docs: Get object attribute using bracket syntax: (object_col).attribute

User_1871
User_1871 Member Posts: 247 Red Ribbon

Could a blurb be added to the docs that explains that the bracket syntax can be used to get an object's attribute?

with cte as (select sdo_geometry('point(10 20)') as shape from dual)

select
  (shape).sdo_gtype
from
  cte

(SHAPE).SDO_GTYPE
-----------------
             2001

...as an alternative to the table alias technique:

2.1.8.1 When Table Aliases Are Required


Oracle Database requires you to use a table alias to qualify any dot-notational reference to subprograms or attributes of objects, to avoid inner capture and similar problems resolving references.

with cte as (select sdo_geometry('point(10 20)') as shape from dual)

select
  a.shape.sdo_gtype
from
  cte a

I think that would be helpful to people of the future.

(It might not be a big deal for a simple query like the above example. But for a large query, eliminating the need for table aliases can help keep a query clean.)

Cheers.

Tagged:
User_1871
1 votes

Active · Last Updated

Comments