<?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 can't use Left() function in query? in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/can-t-use-left-function-in-query/m-p/90131#M399</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;BR /&gt;&lt;SPAN&gt;We are using ArcGIS Server 9.3.1, Java, and ArcSDE with SQL Server 2005 sp2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be very useful for us to be able to monitor our data periodically for defects, with a query such as&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp; select * from sdeDLM.SDE.Lang_Polygons
&amp;nbsp;&amp;nbsp; where ISO_LANGUAGE_CODE_ID &amp;lt;&amp;gt; LEFT(ID , 3)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArcMap, I can do that query using Select by Attributes. I enter the above where clause and click 'Verify', and the expression is verified successfully.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But in order to monitor the data we need to use the REST API. We can successfully do REST queries with a where clause such as &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ISO_LANGUAGE_CODE_ID IS NULL&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;That works just fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The URL is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://ourServer:8399/arcgis/rest/services/DLM21_query/MapServer/2/query?text=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;where=ISO_LANGUAGE_CODE_ID+is+NULL&amp;amp;returnGeometry=false&amp;amp;outSR=&amp;amp;outFields=&amp;amp;f=html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://ourServer:8399/arcgis/rest/services/DLM21_query/MapServer/2/query?text=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;where=ISO_LANGUAGE_CODE_ID+is+NULL&amp;amp;returnGeometry=false&amp;amp;outSR=&amp;amp;outFields=&amp;amp;f=html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I try a REST query with a where clause like &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ISO_LANGUAGE_CODE_ID &amp;lt;&amp;gt; LEFT(ID , 3)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;the REST API returns the message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Unable to perform query. Please check your parameters&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As best I can tell, it's the LEFT() function that makes the difference. I have been able to successfully use where clauses with everything else in them, including '&amp;lt;&amp;gt;'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The REST API docs (&lt;/SPAN&gt;&lt;A href="http://resources.esri.com/help/9.3/arcgisserver/apis/rest/query.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.esri.com/help/9.3/arcgisserver/apis/rest/query.html&lt;/A&gt;&lt;SPAN&gt;) say that "Any legal SQL where clause operating on the fields in the layer is allowed."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to get the REST API to accept a where clause using Left()? Or a way to find out why it's not working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried browsing the latest logs in C:\Program Files\ArcGIS\server\user\log. The file Server-20100929-143218.dat shows the following output from the time when the query failed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;String request received. Request size is 2629 characters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;QueryFeatureData2 has started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Preparation for method: QueryFeatureData2 has started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Preparation for method: QueryFeatureData2 has completed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Query Operation for method: QueryFeatureData2 on layer &amp;amp;apos;Language Polygons&amp;amp;apos; has started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;GeoDatabase Error :An invalid SQL statement was used.&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;QueryFeatureData2 has completed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Method failed.HRESULT = 0x80040207 : This is a FACILITY_ITF error that is specific to the interface that returned this error. See the documentation of the interface that returned this error for information about this HRESULT.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ERROR INFO = An invalid SQL statement was used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But clearly the WHERE clause has been tested as valid elsewhere. And why would some of my WHERE clauses be accepted as valid, but not the one with LEFT() in it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lars&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 23:26:55 GMT</pubDate>
    <dc:creator>LarsHuttar</dc:creator>
    <dc:date>2021-12-10T23:26:55Z</dc:date>
    <item>
      <title>can't use Left() function in query?</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/can-t-use-left-function-in-query/m-p/90131#M399</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;BR /&gt;&lt;SPAN&gt;We are using ArcGIS Server 9.3.1, Java, and ArcSDE with SQL Server 2005 sp2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be very useful for us to be able to monitor our data periodically for defects, with a query such as&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp; select * from sdeDLM.SDE.Lang_Polygons
&amp;nbsp;&amp;nbsp; where ISO_LANGUAGE_CODE_ID &amp;lt;&amp;gt; LEFT(ID , 3)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArcMap, I can do that query using Select by Attributes. I enter the above where clause and click 'Verify', and the expression is verified successfully.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But in order to monitor the data we need to use the REST API. We can successfully do REST queries with a where clause such as &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ISO_LANGUAGE_CODE_ID IS NULL&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;That works just fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The URL is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://ourServer:8399/arcgis/rest/services/DLM21_query/MapServer/2/query?text=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;where=ISO_LANGUAGE_CODE_ID+is+NULL&amp;amp;returnGeometry=false&amp;amp;outSR=&amp;amp;outFields=&amp;amp;f=html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://ourServer:8399/arcgis/rest/services/DLM21_query/MapServer/2/query?text=&amp;amp;geometry=&amp;amp;geometryType=esriGeometryEnvelope&amp;amp;inSR=&amp;amp;spatialRel=esriSpatialRelIntersects&amp;amp;where=ISO_LANGUAGE_CODE_ID+is+NULL&amp;amp;returnGeometry=false&amp;amp;outSR=&amp;amp;outFields=&amp;amp;f=html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But when I try a REST query with a where clause like &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ISO_LANGUAGE_CODE_ID &amp;lt;&amp;gt; LEFT(ID , 3)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;the REST API returns the message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Unable to perform query. Please check your parameters&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As best I can tell, it's the LEFT() function that makes the difference. I have been able to successfully use where clauses with everything else in them, including '&amp;lt;&amp;gt;'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The REST API docs (&lt;/SPAN&gt;&lt;A href="http://resources.esri.com/help/9.3/arcgisserver/apis/rest/query.html" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.esri.com/help/9.3/arcgisserver/apis/rest/query.html&lt;/A&gt;&lt;SPAN&gt;) say that "Any legal SQL where clause operating on the fields in the layer is allowed."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to get the REST API to accept a where clause using Left()? Or a way to find out why it's not working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried browsing the latest logs in C:\Program Files\ArcGIS\server\user\log. The file Server-20100929-143218.dat shows the following output from the time when the query failed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;String request received. Request size is 2629 characters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;QueryFeatureData2 has started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Preparation for method: QueryFeatureData2 has started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Preparation for method: QueryFeatureData2 has completed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Query Operation for method: QueryFeatureData2 on layer &amp;amp;apos;Language Polygons&amp;amp;apos; has started.&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;GeoDatabase Error :An invalid SQL statement was used.&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;QueryFeatureData2 has completed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Method failed.HRESULT = 0x80040207 : This is a FACILITY_ITF error that is specific to the interface that returned this error. See the documentation of the interface that returned this error for information about this HRESULT.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ERROR INFO = An invalid SQL statement was used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But clearly the WHERE clause has been tested as valid elsewhere. And why would some of my WHERE clauses be accepted as valid, but not the one with LEFT() in it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Lars&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 23:26:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/can-t-use-left-function-in-query/m-p/90131#M399</guid>
      <dc:creator>LarsHuttar</dc:creator>
      <dc:date>2021-12-10T23:26:55Z</dc:date>
    </item>
  </channel>
</rss>

