1

I have an Oracle 10.7.1 geodatabase that has tables and feature classes with subtypes.

How can I extract the codes and descriptions from the subtypes in a view?

0

For a non-spatial table:

select
    cast(substr(extractvalue(fields.column_value,'/Subtype/SubtypeCode'),1,255) as number(9,0)) as code,
    substr(extractvalue(fields.column_value,'/Subtype/SubtypeName'),1,255) as description
from
    sde.gdb_items_vw,
    table (xmlsequence(xmltype(definition).extract('/DETableInfo/Subtypes/Subtype'))) fields
where
    name = 'OWNER.YOUR_NON_SPATIAL_TABLE'

For a feature class:

select
    cast(substr(extractvalue(fields.column_value,'/Subtype/SubtypeCode'),1,255) as number(9,0)) as code,
    substr(extractvalue(fields.column_value,'/Subtype/SubtypeName'),1,255) as description
from
    sde.gdb_items_vw,
    table (xmlsequence(xmltype(definition).extract('/DEFeatureClassInfo/Subtypes/Subtype'))) fields
where
    name = 'OWNER.YOUR_FEATURE_CLASS'

Notes:

  • The difference between the XML path of the non-spatial table vs. the feature class is in this part: /DETableInfo vs. /DEFeatureClassInfo
  • The string literals are case-sensitive. Examples: 'CodedValue/Code', '/GPCodedValueDomain2/CodedValues/CodedValue',and 'ExampleDomainName'
  • The performance of the views could likely be improved by creating a materialized view on sde.gdb_items_vw (and basing the subtype views on the materialized view).
  • It is also possible to extract a domain's codes and descriptions using similar logic (not included in this answer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.