I am trying to create a .pyt that find and select an object in an specific layer but I have a problem. I'm working on the Desktop version 10.5 and actually the code is this one:
def getParameterInfo(self): """Define parameter definitions""" Cabina = arcpy.Parameter( displayName="Cabina", name="cab", datatype="string", parameterType="Required", direction="Input") params = [Cabina] return params def isLicensed(self): """Set whether tool is licensed to execute.""" return True def updateParameters(self, parameters): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" return def updateMessages(self, parameters): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" return def execute(self, parameters, messages): """The source code of the tool.""" mxd = arcpy.mapping.MapDocument("CURRENT") lyr = arcpy.mapping.Layer(r"ESERCIZIO\ELE_ESER_Cab") exp = "'" + str(Cabina) + "'" arcpy.SelectLayerByAttribute_management(in_layer_or_view= lyr, selection_type="NEW_SELECTION", where_clause= "COD_CABINA LIKE" + exp) arcpy.RefreshActiveView() return `
the problem is that continue to appear this error message: ERROR 000358: Invalid expression Failed to execute. (I'm working in an Oracle environment) Actually I tried to put a value such as exp = 'A0001' and the script work well. I read almost everything but seems like nothing works. I tried to find some documentation about how to use custom input and SQL but I did not find so much.