I can use Oracle's xmltable
function to extract XML values from the definition
column in gdb_items_vw
.
There is a different XML path for feature classes vs. tables. So we need separate queries for feature classes and tables. And then union the queries together.
The queries only get numeric default values. I believe textual default values would use a different XML tag than /DefaultValueNumeric
.
select
i.name as object_name,
x.column_name as column_name,
x.default_value as numeric_default_value,
'Table' as object_type
from
sde.gdb_items_vw i
cross apply xmltable(
'/DETableInfo/GPFieldInfoExs/GPFieldInfoEx'
passing xmltype(i.definition)
columns
column_name varchar2(50) path './Name',
default_value varchar2(255) path './DefaultValueNumeric'
) x
where
i.name is not null
and x.default_value is not null
and i.name like 'INFRASTR.%'
union all
select
i.name as object_name,
x.column_name as column_name,
default_value as numeric_default_value,
'Feature Class' as object_type
from
sde.gdb_items_vw i
cross apply xmltable(
'/DEFeatureClassInfo/GPFieldInfoExs/GPFieldInfoEx'
passing xmltype(i.definition)
columns
column_name varchar2(50) path './Name',
default_value varchar2(255) path './DefaultValueNumeric'
) x
where
i.name is not null
and x.default_value is not null
and i.name like 'INFRASTR.%'
order by
object_name
Edit:
As @John pointed out, I forgot that subtype fields have their own default values. So, the queries below handle that case: get the subtype field default values.
Notes:
- It looks like the query gets both numeric and textual default values (unlike the non-subtype queries above).
- The queries could be unioned with the above non-subtype queries. But I suppose the fields would need to be changed first so that they align.
select
i.name as table_name,
x.subtype_code,
x.subtype_description,
x.subtype_field,
-- x.subtype_field_domain,
x.subtype_field_default_value
from
sde.gdb_items_vw i
cross apply xmltable(
'/DETableInfo/Subtypes/Subtype/FieldInfos/SubtypeFieldInfo'--[FieldName="ACTIVITY"]'
passing xmltype(i.definition)
columns
subtype_code number(38,0) path './../../SubtypeCode',
subtype_description varchar2(255) path './../../SubtypeName',
subtype_field varchar2(255) path './FieldName',
-- subtype_field_domain varchar2(255) path './DomainName',
subtype_field_default_value varchar2(255) path './DefaultValue'
) x
where
i.name is not null
and i.name like 'INFRASTR.%'
and x.subtype_field_default_value is not null
union all
select
i.name as table_name,
x.subtype_code,
x.subtype_description,
x.subtype_field,
-- x.subtype_field_domain,
x.subtype_field_default_value
from
sde.gdb_items_vw i
cross apply xmltable(
'/DEFeatureClassInfo/Subtypes/Subtype/FieldInfos/SubtypeFieldInfo'--[FieldName="ACTIVITY"]'
passing xmltype(i.definition)
columns
subtype_code number(38,0) path './../../SubtypeCode',
subtype_description varchar2(255) path './../../SubtypeName',
subtype_field varchar2(255) path './FieldName',
-- subtype_field_domain varchar2(255) path './DomainName',
subtype_field_default_value varchar2(255) path './DefaultValue'
) x
where
i.name is not null
and i.name like 'INFRASTR.%'
and x.subtype_field_default_value is not null