1

I have a layer and the query for layer is a select query consisting of ID field in it. This query is being executed on top of Oracle and its throwing an exception for field "ID" when "ID" field is being set as OIDFields in below code. ID is suppose to be the key field for a layer. I tried using try/catch to see what happens and it turns out that below code is setting all the fields in the layer as key. My issue is how can i set an "ID" returned by a select query of a layer as OIDFields.

IQueryDescription qd = sw.GetQueryDescription(layerQuery);
try
{                        
    qd.OIDFields = c.OIDFieldName;                                        
}
catch (Exception ex)
{ 

}
qd.GeometryType = c.ShapeType;
qd.SpatialReference = (mapLayer as IFeatureLayer).AreaOfInterest.SpatialReference;
  • What is the fieldtype for the ID found in IQueryDescription.Fields ? With SQL Server I was puzzled to see that it was esriFieldtypeDouble in some cases when I was expecting it to be integer. – Kirk Kuykendall Jun 12 '18 at 1:03
  • I am using Oracle and the fieldtype is esriFieldTypeOID. – jay Jun 12 '18 at 1:05
  • What are the other property values of qd (e.g. IsOIDMappedColumn)? – Kirk Kuykendall Jun 12 '18 at 1:12
  • Does OIDFields already have a value before you set it? – Kirk Kuykendall Jun 12 '18 at 1:13
  • Yes, It's just like I take a layer update it to point to different database server for an example from development database server to test database server and then create new feature class and assign it to current layer feature class. See following code. sw.CheckDatasetName(mapLayer.Name, qd, out queryClassName); IFeatureClass newFc = sw.OpenQueryClass(queryClassName, qd) as IFeatureClass; (mapLayer as IFeatureLayer).FeatureClass = newFc; "sw" is ISqlWorkspace – jay Jun 12 '18 at 1:17

Your Answer

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

Browse other questions tagged or ask your own question.