<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic SelectLayerByAttribute issue in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-issue/m-p/353108#M27708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have had issues whereby a SelectLayerByAttribute CLEAR_SELECTION and NEW_SELECTION is producing "The value cannot be a feature class" messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I googled this and found that I should make my class a layer either by using MakeFeatureLayer or MakeTableView for the layer to be selected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried both these but still get the same message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated. My code is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, sys, math, os, datetime, traceback
import arcpy.mapping as map
from arcpy import da, env

XYPointsLayer = layerMemory + os.sep + "XYPointsLayer"
XYPointsLayerIntersect = layerMemory + os.sep + "XYPointsLayerIntersect"
#arcpy.MakeXYEventLayer_management(WorkLayerName, viewName&amp;nbsp; + ".GRID_X", viewName&amp;nbsp; + ".GRID_Y", XYPointsLayer)
arcpy.MakeXYEventLayer_management(fullviewName, "GRID_X", "GRID_Y", XYPointsLayer)
#### Note looks like using the view directly may work instead of the MakeQueryTable option
arcpy.MakeTableView_management(XYPointsLayer, XYPointsLayerIntersect)
#arcpy.MakeFeatureLayer_management(XYPointsLayer, XYPointsLayerIntersect)

viewName = "DWOP.DBO.VWO_MDPAG_DPA_WORK"
fullviewName = arcpy.env.workspace + os.sep + viewName


arcpy.SelectLayerByAttribute_management(XYPointsLayerIntersect,"CLEAR_SELECTION")
arcpy.SelectLayerByAttribute_management(XYPointsLayerIntersect,"NEW_SELECTION","TIMESTAMP0 = '20140613 08:59:58.063' and FK_ROADLINK_TOID = 'PEGASUS005108964' and AP_ID_ARRAY1 = '141863003'")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The SelectLayerByAttribute is within an "for" statement in the original code so i am wondering if this may be an issue? Also, the "NEW_SELECTION" criteria are in a variable in the original code but I have traced this and cut and pasted these in just to show the criteria used. However, it fails on the CLEAR_SELECTION first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The issue seems to be the basic interpretation of what XYPointsLayerIntersect actually is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Jun 2014 08:59:37 GMT</pubDate>
    <dc:creator>MarkWingfield</dc:creator>
    <dc:date>2014-06-16T08:59:37Z</dc:date>
    <item>
      <title>SelectLayerByAttribute issue</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-issue/m-p/353108#M27708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have had issues whereby a SelectLayerByAttribute CLEAR_SELECTION and NEW_SELECTION is producing "The value cannot be a feature class" messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I googled this and found that I should make my class a layer either by using MakeFeatureLayer or MakeTableView for the layer to be selected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried both these but still get the same message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be appreciated. My code is below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy, sys, math, os, datetime, traceback
import arcpy.mapping as map
from arcpy import da, env

XYPointsLayer = layerMemory + os.sep + "XYPointsLayer"
XYPointsLayerIntersect = layerMemory + os.sep + "XYPointsLayerIntersect"
#arcpy.MakeXYEventLayer_management(WorkLayerName, viewName&amp;nbsp; + ".GRID_X", viewName&amp;nbsp; + ".GRID_Y", XYPointsLayer)
arcpy.MakeXYEventLayer_management(fullviewName, "GRID_X", "GRID_Y", XYPointsLayer)
#### Note looks like using the view directly may work instead of the MakeQueryTable option
arcpy.MakeTableView_management(XYPointsLayer, XYPointsLayerIntersect)
#arcpy.MakeFeatureLayer_management(XYPointsLayer, XYPointsLayerIntersect)

viewName = "DWOP.DBO.VWO_MDPAG_DPA_WORK"
fullviewName = arcpy.env.workspace + os.sep + viewName


arcpy.SelectLayerByAttribute_management(XYPointsLayerIntersect,"CLEAR_SELECTION")
arcpy.SelectLayerByAttribute_management(XYPointsLayerIntersect,"NEW_SELECTION","TIMESTAMP0 = '20140613 08:59:58.063' and FK_ROADLINK_TOID = 'PEGASUS005108964' and AP_ID_ARRAY1 = '141863003'")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The SelectLayerByAttribute is within an "for" statement in the original code so i am wondering if this may be an issue? Also, the "NEW_SELECTION" criteria are in a variable in the original code but I have traced this and cut and pasted these in just to show the criteria used. However, it fails on the CLEAR_SELECTION first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The issue seems to be the basic interpretation of what XYPointsLayerIntersect actually is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jun 2014 08:59:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-issue/m-p/353108#M27708</guid>
      <dc:creator>MarkWingfield</dc:creator>
      <dc:date>2014-06-16T08:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute issue</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-issue/m-p/353109#M27709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Perhaps try this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy, sys, math, os, datetime, traceback
import arcpy.mapping as map
from arcpy import da, env

XYPointsLayer = layerMemory + os.sep + "XYPointsLayer"
#XYPointsLayerIntersect = layerMemory + os.sep + "XYPointsLayerIntersect"
#arcpy.MakeXYEventLayer_management(WorkLayerName, viewName&amp;nbsp; + ".GRID_X", viewName&amp;nbsp; + ".GRID_Y", XYPointsLayer)
arcpy.MakeXYEventLayer_management(fullviewName, "GRID_X", "GRID_Y", XYPointsLayer)
#### Note looks like using the view directly may work instead of the MakeQueryTable option
XYPointsLayerIntersect = arcpy.MakeTableView_management(XYPointsLayer, "Test")
#arcpy.MakeFeatureLayer_management(XYPointsLayer, XYPointsLayerIntersect)

viewName = "DWOP.DBO.VWO_MDPAG_DPA_WORK"
fullviewName = arcpy.env.workspace + os.sep + viewName


arcpy.SelectLayerByAttribute_management(XYPointsLayerIntersect,"CLEAR_SELECTION")
arcpy.SelectLayerByAttribute_management(XYPointsLayerIntersect,"NEW_SELECTION","TIMESTAMP0 = '20140613 08:59:58.063' and FK_ROADLINK_TOID = 'PEGASUS005108964' and AP_ID_ARRAY1 = '141863003'")

&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only thing that I can think of is that arcpy is interpreting the string value you were setting for XYPointsLayerIntersect as a file path, not a layer name.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:34:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-issue/m-p/353109#M27709</guid>
      <dc:creator>DouglasSands</dc:creator>
      <dc:date>2021-12-11T16:34:02Z</dc:date>
    </item>
  </channel>
</rss>

