AnsweredAssumed Answered

Setting OID Fields in Make Query Layer Function

Question asked by BrokenLegMike on Jun 2, 2016
Latest reply on Nov 14, 2018 by env.matt.wilkie

Hey all, I am trying to use the:


funtion using arcpy in ArcGIS 10.3.


Make Query Layer—Data Management toolbox | ArcGIS for Desktop


I am trying to set 2 fields as the OID fields (parameter #4). For the life of me, I can't get them to set in the resulting Query Layer. It will set the first one field, but not the second one. I am running this from both a python addin and from the built in python command line window in ArcMap:


arcpy.MakeQueryLayer_management (r"Database Connections\XXXX.sde", "Table_Test3", "select a.tenure_number_id, b.event_number_id from mta_acquired_tenure_svw a, mta_event c, mta_tenure_event_xref b where a.tenure_number_id = b.tenure_number_id and b.event_number_id = c.event_number_id", "TENURE_NUMBER_ID (Long Integer, Not nullable);EVENT_NUMBER_ID (Long Integer, Not nullable)")


The fields are valid. If I were to create a Query layer via the GUI in ArcMap (i.e. File-->Add Data-->Add Query Layer...), the query layer successfully populates and both the OID fields are set because I can manually check off each layer in the second page of the dialogue box. I tried reversing the fields in the query (shot in the dark) and what I've noticed is, it will set the first field in the table as the OID, but not the second. I've tried using the table aliases in the field names. No luck. Any suggestions? thanks.