AnsweredAssumed Answered

error in SelectLayerByAttribute

Question asked by helenak on May 5, 2012
Latest reply on May 9, 2012 by fabl

System: ArcGIS 9.3
pythonWin: 2.5

Problem 1:
Using SelectLayerByAttribute but error showed:
ExecuteError: ERROR 000358: Invalid expression

Please kindly help indicate the mistake in the query code.
Also, a shape file is attached for trial.
Thanks a lot.

 ##Script Name: Delete rows ##Description: delete selected rows ##Created By: Elaine Kuo ##Date: 04/05/2012  #Import standard library modules import arcgisscripting import os  #Create the Geoprocessor object gp = arcgisscripting.create(9.3)  #Set the input workspace #GP.workspace = sys.argv[1] #Set the workspace. gp.Workspace= "G:/temp"  #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset outWorkspace= "G:/temp/test"  #Get a list of the featureclasses in the input folder fcs = gp.ListFeatureClasses()  # Loop through every item in the list that was just generated for fc in fcs:      # Break out the name, no path or extension, using the describe object.     desc = gp.describe(fc)     featureName =      # Make featureclasses as layers     gp.OverWriteOutput = 1     gp.toolbox = "Data Management"     gp.MakeFeatureLayer("geor0313_p.shp","geor0313_p_lyr")          #Get a list of the fields in the featureclass     fields = gp.ListFields("geor0313_p_lyr", "C*", "String")      # Loop through every item in the list that was just generated      for field in fields:          gp.toolbox = "Data Management"               # Select records to be deleted (C*, i.e. C7658)         query = "\"C*\" = 'R'"         gp.SelectLayerByAttribute("geor0313_p_lyr", "ADD_TO_SELECTION", query)          # Delete selected records         gp.deleterows("geor0313_p_lyr")              #Validate the new feature class name for the output workspace.     outFeatureClass = outWorkspace + os.sep +GP.ValidateTableName("geor0313_p_lyr",outWorkspace)