<?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: SelectByAttribute ERROR 000358: Invalid expression in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715136#M23682</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try changing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase1 = "\"Line_No\" =" + str(LineNo) + " AND \"Station_No\" &amp;gt; " + str(FromStation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase2 = "\"To_Station\" &amp;lt;=" + str(ToStation&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase1 = "Line_No = " + str(LineNo) + " AND Station_No &amp;gt; " + str(FromStation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase2 = "To_Station &amp;lt;= " + str(ToStation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thhat is, get rid of all the \s&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Dec 2010 21:07:49 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2010-12-03T21:07:49Z</dc:date>
    <item>
      <title>SelectByAttribute ERROR 000358: Invalid expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715131#M23677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Bellow is a python script originated from a model and modified by me for certain needs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This code is applied to data elements (i.e. tables /feature classes) stored within perssonal SDE environment, built on top of SQL Server Express (2008). The ArcGIS version is 9.3.1, with the default python installation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When executing the script I keep getting the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000358: Invalid expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the relevant part of the code that might cause that problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;tblrows = gp.searchcursor (Table_View)
tblrow = tblrows.next()

while tblrows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; myDate = tblrow.getvalue ("Date")
&amp;nbsp;&amp;nbsp;&amp;nbsp; LineNo = tblrow.getvalue ("route_No")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FromStation = tblrow.getvalue ("From_place")
&amp;nbsp;&amp;nbsp;&amp;nbsp; ToStation = tblrow.getvalue ("To_place")
&amp;nbsp;&amp;nbsp;&amp;nbsp; Status = 1 #tblrow.getvalue ("Status")

&amp;nbsp;&amp;nbsp;&amp;nbsp; phrase1 = "\"Line_No\" =" + str(LineNo) + " AND \"Station_No\" &amp;gt; " + str(FromStation)
&amp;nbsp;&amp;nbsp;&amp;nbsp; phrase2 = "\"To_Station\" &amp;lt;=" + str(ToStation)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: = Line_No and &amp;gt; FromStation...
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByAttribute_management(Demining_Layer, "NEW_SELECTION", phrase1)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: &amp;lt;= ToStation...
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.SelectLayerByAttribute_management(Flags_Layer, "SUBSET_SELECTION", phrase2)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Update Visit Date...
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CalculateField_management(Station_to_be_Updated, "Visit_Date", myDate, "VB", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Process: Update Status...
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.CalculateField_management(Flags_Layer__3_, "Status", str(Status), "VB", "")

&amp;nbsp;&amp;nbsp;&amp;nbsp; myDate = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; LineNo = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; FromStation = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; ToStation = ""
&amp;nbsp;&amp;nbsp;&amp;nbsp; Status = ""

&amp;nbsp;&amp;nbsp;&amp;nbsp; tblrow = tblrows.next ()


del tblrow
del tblrows&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess it's got something to do with the way I'm transfering the sql phrase to the&amp;nbsp; SelectByAttribute tools, but I can't put my finger at the exact spot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help will be appreciated&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gal&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Apr 2010 10:13:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715131#M23677</guid>
      <dc:creator>GalAvraham</dc:creator>
      <dc:date>2010-04-03T10:13:41Z</dc:date>
    </item>
    <item>
      <title>SelectByAttribute ERROR 000358: Invalid expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715132#M23678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;should this line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while tblrows&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;not be &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while tblrow&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 04 Apr 2010 12:27:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715132#M23678</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-04-04T12:27:59Z</dc:date>
    </item>
    <item>
      <title>follow up... given the new forum format</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715133#M23679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;just curious... was that it? or are there further errors? or does the forum not allow for threads to be finished?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Apr 2010 01:30:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715133#M23679</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2010-04-15T01:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: SelectByAttribute ERROR 000358: Invalid expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715134#M23680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I built a model in model builder that selected polygons by attributes, and had it set up where the selection criteria was entered as user defined parameters...worked fine.&amp;nbsp; I exported the model to a python script and initially it worked fine, but the interactive parameters were not active, just default values from when I built it, but it worked.&amp;nbsp; I edited the script properties to add parameters and now it wont run.&amp;nbsp; It keeps giving me the error shown below.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And what is with the "Running script test..." and "failed to execute (test)"&amp;nbsp; no part of the name is test &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script test...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000358: Invalid expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (test).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be greatly appreciated&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Sep 2010 20:02:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715134#M23680</guid>
      <dc:creator>MikeHouts</dc:creator>
      <dc:date>2010-09-10T20:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: SelectByAttribute ERROR 000358: Invalid expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715135#M23681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are selecting data from a string field or any non number field than you need to add single quotes around the value being selected.&amp;nbsp; Such as..&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase1 = "\"Line_No\" =" + "'"+str(LineNo)+"'" + " AND \"Station_No\" &amp;gt; " + str(FromStation)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 18:45:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715135#M23681</guid>
      <dc:creator>MarkZito</dc:creator>
      <dc:date>2010-12-03T18:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: SelectByAttribute ERROR 000358: Invalid expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715136#M23682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try changing:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase1 = "\"Line_No\" =" + str(LineNo) + " AND \"Station_No\" &amp;gt; " + str(FromStation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase2 = "\"To_Station\" &amp;lt;=" + str(ToStation&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;to this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase1 = "Line_No = " + str(LineNo) + " AND Station_No &amp;gt; " + str(FromStation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;phrase2 = "To_Station &amp;lt;= " + str(ToStation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thhat is, get rid of all the \s&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Dec 2010 21:07:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectbyattribute-error-000358-invalid-expression/m-p/715136#M23682</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-12-03T21:07:49Z</dc:date>
    </item>
  </channel>
</rss>

