Hello! When a geodatabase view references a field to which a coded value domain has been applied, the code, rather than the human readable value, is exposed. Having made extensive use of coded value domains, this makes views useless for my environment. Does anyone know of a workaround?Thank you!ArcSDE1 10.0/SQL Server 2008 R2
Thank you for the timely response! It helped me implement it right away.
You could build a db view using the select statement by just putting it into a create view statement, something like
create view your_new_view_name as
select .....
However, the view is then a static pointer to the domain and subtype values as they existed at the time of creation of the view. If you ever change any of the domain values or modify the subtypes, you'll need to drop and re-create the view using an updated sql statement.
You could also use the returned select statement to pass into the Create Database View GP tool and that would achieve the same result as doing it via. sql.
Hello,
I have been playing with your script and I see how it could be very useful. Would you mind explaining the best way to go about implementing this into a enterprise database view in Pro?
The attached python toolbox might help. It contains tools to decode domain values using SQL. The tool is currently SQL Server specific, but could be modified for other db platforms. Basically, it just builds a big SQL statement with a bunch of case statements in it which translate the domain values to human readable text for use in a view. There are two tools which use the same backend code. The first just returns the sql select statement as a string (useful if you are building this into a larger model or tool) and the second uses the select statement to return a query layer. You can always go back and examine the sql via. the source for the feature layer if needed. The code works with layers that are subtyped as well as those that aren't.
Related: File Geodatabase views should support domains
Our geodatabase is Oracle, not SQL Server. What I do is create individual views to get the domain values (codes and descriptions) for a given domain.
--This is Oracle-specific SQL. You'll need something different for SQL Server. https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/example-resolving-domain-codes-to-description-values.htmcreate or replace view d_atn_type asselect cast(rownum as number(38,0)) as rownum_, x.code, x.description, i.name as domain_name from sde.gdb_items_vw i cross apply xmltable( '/GPCodedValueDomain2/CodedValues/CodedValue' passing xmltype(i.definition) columns code varchar2(255) path './Code', description varchar2(255) path './Name' ) x where i.name = 'ATN_TYPE'
That works well for me.
Alternatively, you could create a view that includes the domain codes/descriptions for ALL coded value domains in the geodatabase, or just for a given owner/user/schema. And include the domain name as a column in the view.
Then, when you want to use a specific domain's values in your FC view, you could join to the domain view, but only include the rows that pertain to the applicable domain.
That is a good thought. Although, I'd be worried about the domains being disconnected from the tables in case future changes to the domains occur. XML is a queryable datatype within SQL. For example, in SQL Server, there is documentation on how to do it and plenty of examples of how to join that XML to a table in a query. So I would say this should be possible without making static tables of the domains.
Since ArcGIS Enterprise / ArcMap 10.6 and ArcGIS Pro 2.7 (please correct my version numbers if I'm incorrect), the user has had the ability to register database views with the geodatabase. Once I register a database view with the geodatabase, I would expect that it has full geodatabase functionality, including displaying domain descriptions instead of values.
Esri Canada technical support pointed us to this example, which we've tried and it works as expected. However, I would expect that this would be implemented by Esri out-of-the-box.
I would have expected that view to behave as any other geodatabase table behaves i.e. - to be geodatabase aware.
Since Esri enabled ArcGIS Desktop to create a view (as of 10.1, I believe), I would have expected that view to behave as any other geodatabase table behaves i.e. - to be geodatabase aware. But in this case, it's just a button which performs a non-geodatabase function.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.