Database.OpenTable work very selective, throws exception otherwise

389
6
Jump to solution
01-30-2019 04:34 AM
TomGeo
by
Occasional Contributor III

To minimize the overhead I am asking an Oracle database table only for specific objects through the OpenTable method.

While it works with in the first attempt, all others fail. I do not know what the issue is but I am getting an ArcGIS.Core.Data.GeodatabaseQueryexception thrown when trying to open the table based on my query description.

Below is the code how I am trying to get the data. The exception thrown is pointing to "Geometry is null geometry" which is strange since I can find multiple objects that fulfil the SQL statement.

public async void SearchValidationTables()
        {
            await QueuedTask.Run(() =>
            {
                using (Database ValidationDatabase = new Database(connectionFileValidation))
                {
                    // get national string prefix
                    string nationalStringPrefix = "";
                    SQLSyntax sqlSyntax = ValidationDatabase.GetSQLSyntax();
                    nationalStringPrefix = sqlSyntax.GetSupportedStrings(SQLStringType.NationalStringPrefix).First();
                    // build query here and set it into next line
                    string querySQL = "SELECT * FROM SCHEMA.DBTABLE WHERE FEATURETYPE = "+ nationalStringPrefix +"'waterways'";
                    QueryDescription queryDescription = ValidationDatabase.GetQueryDescription(querySQL, "test");
                    // set the column with a unique identifier
                    queryDescription.SetObjectIDFields("OBJECTID");
                    // get data as featureclass and load it as featurelayer
                    try
                    {
                        FeatureClass fcFromTable = ValidationDatabase.OpenTable(queryDescription) as FeatureClass;
                        LayerFactory.Instance.CreateFeatureLayer(fcFromTable, MapView.Active.Map);
                    }
                    catch (GeodatabaseQueryException e)
                    {

                        throw e;
                    }
                    
                }
            });
        }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I found a bit more information by looking at the inner exception:

Does that mean I have to adjust the QueryLayerName?

-------------------------
“GIS is a form of digital mapping technology. Kind of like Google Earth, but better.” ~ Arnold Schwarzenegger
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RichRuh
Esri Regular Contributor

Thomas,

Could you try setting the QueryDescription shape type?

For example, add the following after line 15 above:

queryDescription.SetShapeType(GeometryType.Polyline); // assuming the underlying geometry type is polyline

I hope this helps,

--Rich

View solution in original post

6 Replies
RichRuh
Esri Regular Contributor

Thomas,

Could you try setting the QueryDescription shape type?

For example, add the following after line 15 above:

queryDescription.SetShapeType(GeometryType.Polyline); // assuming the underlying geometry type is polyline

I hope this helps,

--Rich

TomGeo
by
Occasional Contributor III

Thanks Rich, that certainly helped. May I ask how you figured out that's the issue?

And, of course, now there is another problem... The FeatureLayer is added to the TOC, but the attempt to visualize some features isn't successful and when I try to see feature attributes then I am getting an error returned, pointing at the SRID:

The active maps coordinate system is set to ETRS 1989 UTM Zone 32N and I get and set the spatial reference of the queryDescription through:

SpatialReference sr = MapView.Active.Map.SpatialReference;
queryDescription.SetSpatialReference(sr);

I also checked the database table, where the SDO_SRID of the geometry column is saying 25832.

Still, the error remains. Any good ideas on how to overcome that one?

-------------------------
“GIS is a form of digital mapping technology. Kind of like Google Earth, but better.” ~ Arnold Schwarzenegger
0 Kudos
RichRuh
Esri Regular Contributor

We read the spatial type from the first feature that we find.  Without an Order By, you can get features back in variable order- this would explain why it sometimes worked and sometimes didn't.

As for the spatial reference error, I don't have any immediate ideas.  What line of SDK code is causing the error?

--Rich

0 Kudos
TomGeo
by
Occasional Contributor III

Actually, the error message is not pointing to any line in the C# code, but is raised by ArcGIS Pro, shortly after I try to open the attribute table.
I found a discussion about the same problem here Oracle community but cannot make heads and tails out of it on how to implement that.

Thomas

-------------------------
“GIS is a form of digital mapping technology. Kind of like Google Earth, but better.” ~ Arnold Schwarzenegger
0 Kudos
RichRuh
Esri Regular Contributor

One idea would be to write some test code that steps through every row in the table and see if one of them is corrupt in some way.  

The only other suggestion I have is to log this one with technical support.  I don't have any idea what could cause this error.

--Rich

0 Kudos
TomGeo
by
Occasional Contributor III

Thanks Rich,

i think I will follow your advice and loop through the features to look for corruption.

Thomas

-------------------------
“GIS is a form of digital mapping technology. Kind of like Google Earth, but better.” ~ Arnold Schwarzenegger
0 Kudos