<?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 Re: An invalid SQL statement was used in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067259#M25596</link>
    <description>&lt;P&gt;Please check that the variable field contains the actual field name and not an alias.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# from your code above:
liste = ["speed100m"]

# each element of liste has to be an actual field name, not an alias!&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 11 Jun 2021 08:20:11 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-06-11T08:20:11Z</dc:date>
    <item>
      <title>An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066786#M25585</link>
      <description>&lt;P&gt;Hello, I created a function to round the values of the results on my script which queries the atlases by selecting a layout, but when executing it I have the following error: An invalid SQL statement was used.&lt;BR /&gt;here is the function:&amp;nbsp;&lt;/P&gt;&lt;P&gt;for field in liste:&lt;BR /&gt;with arcpy.da.UpdateCursor(r'in_memory/resultats_table', [field]) as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;if row[0] == None:&lt;BR /&gt;pass&lt;BR /&gt;else:&lt;BR /&gt;row[0] = round(row[0], 2)&lt;BR /&gt;cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 08:48:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066786#M25585</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-10T08:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066794#M25587</link>
      <description>&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;where is "liste" defined?&amp;nbsp; What is "field".&lt;/P&gt;&lt;P&gt;Code formatting will allow one to assess syntax errors.&lt;/P&gt;&lt;P&gt;Finally don't use row[0] == None.&lt;/P&gt;&lt;P&gt;If you want to be explicit use&lt;/P&gt;&lt;P&gt;if row[0] is None:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 09:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066794#M25587</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-10T09:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066805#M25589</link>
      <description>&lt;P&gt;Hello, thanks for your reply, I used row is none but I still have the same error.&lt;BR /&gt;here is the code for the full script :&lt;/P&gt;&lt;P&gt;# Import system modules&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;from arcpy.sa import *&lt;/P&gt;&lt;P&gt;# Set local variables&lt;BR /&gt;input_layout = arcpy.GetParameter(0)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;arcpy.CopyFeatures_management(input_layout, r'in_memory/resultats_table')&lt;/P&gt;&lt;P&gt;raster = [&lt;BR /&gt;[r"\speed100m.tif", "speed100m"],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;liste = ["speed100m"]&lt;/P&gt;&lt;P&gt;texte = """&lt;BR /&gt;&amp;lt;b&amp;gt;AWS&amp;lt;/b&amp;gt;&lt;BR /&gt;&amp;lt;ul&amp;gt;&lt;BR /&gt;&amp;lt;li&amp;gt;100m &amp;lt;/li&amp;gt;&lt;BR /&gt;&amp;lt;/ul&amp;gt;&lt;/P&gt;&lt;P&gt;# Execute ExtractValuesToPoints&lt;BR /&gt;arcpy.sa.ExtractMultiValuesToPoints(r'in_memory/resultats_table', raster, "NONE")&lt;BR /&gt;# arrondir les colonnes via une liste&lt;BR /&gt;for field in liste:&lt;BR /&gt;with arcpy.da.UpdateCursor(r'in_memory/resultats_table', [field]) as cursor:&lt;BR /&gt;for row in cursor:&lt;BR /&gt;if row[0] is None:&lt;BR /&gt;pass&lt;BR /&gt;else:&lt;BR /&gt;row[0] = round(row[0], 2)&lt;BR /&gt;cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# créer les champs 'longitude_wgs84dd' et 'latitude_wgs84dd'&lt;BR /&gt;arcpy.management.AddField(r'in_memory/resultats_table', "longitude_wgs84dd", "DOUBLE", 11, 8, None, None, "NULLABLE", "NON_REQUIRED", None)&lt;BR /&gt;arcpy.management.AddField(r'in_memory/resultats_table', "latitude_wgs84dd", "DOUBLE", 11, 8, None, None, "NULLABLE", "NON_REQUIRED", None)&lt;BR /&gt;# calculer les champs 'longitude_wgs84dd' et 'latitude_wgs84dd'&lt;BR /&gt;arcpy.management.CalculateGeometryAttributes(r'in_memory/resultats_table', "longitude_wgs84dd POINT_X", None, None, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")&lt;BR /&gt;arcpy.management.CalculateGeometryAttributes(r'in_memory/resultats_table', "latitude_wgs84dd POINT_Y", None, None, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")&lt;/P&gt;&lt;P&gt;# Afficher les résultats&lt;BR /&gt;arcpy.SetParameter(1, texte) # résultat string&lt;BR /&gt;arcpy.SetParameter(2, r'in_memory/resultats_table') # résultat table&lt;/P&gt;&lt;P&gt;arcpy.CopyFeatures_management(r'in_memory/resultats_table', r'in_memory/resultats_feature')&lt;BR /&gt;arcpy.SetParameter(3, r'in_memory/resultats_feature') # résultat FL&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 09:43:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066805#M25589</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-10T09:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066837#M25591</link>
      <description>&lt;P&gt;As Dan pointed out earlier, using code highlighting/formatting is helpful.&amp;nbsp; Also, what line is the error happening on because I don't see where you are using an SQL query at all.&amp;nbsp; Also, please provide the traceback of the error message along with the the error.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 12:52:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1066837#M25591</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-06-10T12:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067244#M25593</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sql_statements.PNG" style="width: 438px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15724iD73DFAA2D27860F1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Sql_statements.PNG" alt="Sql_statements.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 07:56:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067244#M25593</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-11T07:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067248#M25595</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="code.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15725i7FDA05810EAAC7E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="code.PNG" alt="code.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 08:03:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067248#M25595</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-11T08:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067259#M25596</link>
      <description>&lt;P&gt;Please check that the variable field contains the actual field name and not an alias.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# from your code above:
liste = ["speed100m"]

# each element of liste has to be an actual field name, not an alias!&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 11 Jun 2021 08:20:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067259#M25596</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-11T08:20:11Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067272#M25597</link>
      <description>&lt;P&gt;I didn't understand what you mean, can you explain to me please ?.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 08:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067272#M25597</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-11T08:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067292#M25598</link>
      <description>&lt;P&gt;A field of a table can have an alias (alternative name) that is different from its real name. You can use this to make field names more readable in the table view, e.g. using spaces in the name.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1623405362345.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15742i238908008F25AEEE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1623405362345.png" alt="JohannesLindner_0-1623405362345.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The arcpy cursors use SQL in the background. SQL doesn't work with alias names, only with the real ones. Using alias names in the cursor may cause the error you experience.&lt;/P&gt;&lt;P&gt;So if in your example "speed100m" (or another field in liste) is not the real name of the field, that might be the problem.&lt;/P&gt;&lt;P&gt;You can check by doing the ExtractMultiVBaluesToPoints in the python window in ArcGIS or with the toolbox and then looking at the table's fields.&lt;/P&gt;&lt;P&gt;Or, you can print all field names:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.sa.ExtractMultiValuesToPoint(.....)
print([f.name for f in arcpy.ListFields("in_memory/resultats_table")])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some further tips:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for field in liste:
    with arcpy.da.UpdateCursor("in_memory/resultats_table", [field]) as cursor:
        for row in cursor:
            if row[0] is None: # this is wrong in your code!
                pass
            else:
                # row[0] = round(...)  
                # this won't work. row is a tuple, you can't change a tuple's elements.
                # do this instead:
                cursor.updateRow([round(row[0], 2)])


# instead of the check for None, you could do this:
for field in liste:
    with arcpy.da.UpdateCursor("in_memory/resultats_table", [field], "{} IS NOT NULL".format(field)) as cursor:
        for row in cursor:
            cursor.updateRow([round(row[0], 2)])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 10:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067292#M25598</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-06-11T10:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067312#M25599</link>
      <description>&lt;P&gt;as you can see the field names and aliases have the same values&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Fields.PNG" style="width: 686px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15748i02E75CC695204EF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Fields.PNG" alt="Fields.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 12:07:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067312#M25599</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-11T12:07:46Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067314#M25600</link>
      <description>&lt;P&gt;thanck you for your help johannes, but i have the same error.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="same_error.PNG" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/15749i2DDAF5263A1F2537/image-size/large?v=v2&amp;amp;px=999" role="button" title="same_error.PNG" alt="same_error.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 12:16:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067314#M25600</guid>
      <dc:creator>hamidmechouet</dc:creator>
      <dc:date>2021-06-11T12:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: An invalid SQL statement was used</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067393#M25601</link>
      <description>&lt;P&gt;That is because you left in your old code (lines 55-64) and didn't use the suggested code beginning at line 67.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jun 2021 16:10:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/an-invalid-sql-statement-was-used/m-p/1067393#M25601</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-11T16:10:16Z</dc:date>
    </item>
  </channel>
</rss>

