Hi MikeThanks for the advice. I am getting closer...Example 1 (based on your tip, thanks!) works...
# Import system modules
import sys, string, os, arcpy
arcpy.AddMessage("start script....")
lyr = "C:\Temp\gpFun\BRANCHES_VABK.lyr" # includes query
arcpy.AddMessage("Getting count....")
result = arcpy.GetCount_management(lyr)
count = int(result.getOutput(0))
arcpy.AddMessage(str(count))
... now, how to apply query external to the .lyr definition.Example 2 Select layer by attribute fails....# Import system modules
import sys, string, os, arcpy
arcpy.AddMessage("start script....")
lyr = "C:\Temp\gpFun\BRANCHES.lyr"
qry = "KeyInstn = 4019974" # VABK
arcpy.AddMessage(qry)
arcpy.AddMessage("Selecting layer by attribute....")
arcpy.SelectLayerByAttribute_management (lyr, "NEW_SELECTION", qry)
arcpy.AddMessage("Getting count....")
result = arcpy.GetCount_management(lyr)
count = int(result.getOutput(0))
arcpy.AddMessage(str(count))
.... here is the error:<class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid.ERROR 000825: The value is not a layer or table viewERROR 000840: The value is not a Raster Layer.ERROR 000840: The value is not a Mosaic Layer.Failed to execute (SelectLayerByAttribute).Example 3 uses TableSelect...# Import system modules
import sys, string, os, arcpy
arcpy.AddMessage("start script....")
lyr = "C:\Temp\gpFun\BRANCHES.lyr"
qry = "KeyInstn = 4019974" # VABK
arcpy.AddMessage(qry)
arcpy.AddMessage("Table selecting....")
arcpy.TableSelect_analysis(lyr, "c:/temp/gpFun/tempOut.shp", qry)
... this works, but the .shp is a table, not a feature class. This won't work for me. I need to perform spatial operations on this like buffer, etc.Weird. I think there is some missing piece for "reading" Query Layers as features, not rows.BTW, Query Layers aren't geodatabase feature classes. They're actually tables in the DBMS with spatial columns. ESRI application then sees these as shapes. GP/Python seems to have problems seeing them though...Thanks for your help,-Cory