Select to view content in your preferred language

arcPy on query layer

10-07-2011 04:54 AM
New Contributor
I need to make many MXDs which include query layers (NOT through layer definition).  The difference of these MXDs is only the query of the layer.  Is there way to automate this?

0 Kudos
4 Replies
Esri Contributor
Hi Steve,

There is currently no option to create or alter query layers through Python at 9.x or 10.

If you have access to the Beta program you can take a look at the "Make Query Layer" tool in 10.1 Beta.
0 Kudos
Esteemed Contributor
I see the Make Query Layer in the Data Management->Layers and Table Views Toolbox which is great.

I would also like to know if there is the ability to edit a Query Layer, that is already created, through python.  In my scenario, I see many Query Layers created with an Oracle 11g Client connection.  If the back end database gets updated to Oracle 12c (which my organization will probably do within the next 2 years), I would want to update the Query Layer to use the Oracle 12c Client connection instead of the Oracle 11g Client connection.  Is this scenario currently possible through python?
0 Kudos
Regular Contributor

Is it even possible to detect a if a layer is a query layer using ArcPy?

0 Kudos
Occasional Contributor III

Only way I know is to do a describe on the layer and look for the string "%" in the datasetName property. 

0 Kudos