Proper syntax for where clause

2076
1
Jump to solution
08-28-2014 12:58 PM
Zeke
by
Regular Contributor III

Any help on how to properly format the where clause in the following code would be greatly appreciated. I get an Invalid Expression error despite whatever combinations I try. v is a string value. Thanks.

code:

for v in lstFCCvalues:

        try:

            outfeature = os.path.join(fdstarget, v + 'Roads')

            if arcpy.Exists(outfeature): arcpy.Delete_management(outfeature)

            where = arcpy.AddFieldDelimiters(intable, fcc) + ' = ' + v

            arcpy.Select_analysis(intable, outfeature, where)

        except Exception as e:

            exceptionMessage(e)

sample error;

ERROR 000358: Invalid expression "FCC" = A00

Failed to execute (Select).

0 Kudos
1 Solution

Accepted Solutions
Zeke
by
Regular Contributor III

Well, after working on it for a couple hours, then posting it here, I got the solution on my next try. For reference, here it is;

where = arcpy.AddFieldDelimiters(intable, fcc) + ' = \'' + v + '\''

View solution in original post

0 Kudos
1 Reply
Zeke
by
Regular Contributor III

Well, after working on it for a couple hours, then posting it here, I got the solution on my next try. For reference, here it is;

where = arcpy.AddFieldDelimiters(intable, fcc) + ' = \'' + v + '\''

View solution in original post

0 Kudos