<?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 Layer definitions queries don't work in the ArcGis Server 10.4 in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/layer-definitions-queries-don-t-work-in-the-arcgis/m-p/670416#M38015</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Hi,&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I am developing an application using ArcGis Runtime v100.2 and ArcGis server v10.4.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I have a layer with multiple objects with the same shape and I'm using layer definition queries to select objects which are shown to the user.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;To keep things simple my objects are stored in the database in table Objects with columns itemId, value, timestamp and shape.&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Items with the same itemId have always the same shape and for one timestamp one itemId can have at most one value.&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;The approach works if the definition query is very simple (e.g. timestamp = '2018-01-01 12:00') but it doesn't work&amp;nbsp;when I use something more complicated like (selecting most recent value for given point in time):&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;timestamp = (select max(timestamp) from Objects t2 where timestamp &amp;lt;=&amp;nbsp; '2018-01-16 17:00' and itemId = t2.itemId )&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;In such case always all objects are shown. Moreover I cannot find any error or warning message anywhere.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;(Documentation suggests using IN instead of first = but the query doesn't work both cases.)&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;The same behaviour I see when I use the web REST interface.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I have tried profiling the database, and it seems that the query isn't run in the database at all.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I have also tried running the same query in the ArcMap 10.4 and it works fine there (and I can see the query in DB profiler) so I believe that the query must be correct. It of course works also if run directly in the DB.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;My questions are:&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;1. What do I do wrong?&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;2. Are the errors in layer definition queries logged anywhere?&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;3. Is there any detailed information about layer definitions query syntax?&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;For quick tests the query that also doesn't work in the REST interface but works in the ArcMap is:&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;itemId % 2 = 3&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Where itemId can be&amp;nbsp;any integer column, % is the&amp;nbsp;MOD operation. In the REST interface it returns all items (and it's not run against the database) and in the ArcMap it rerurns no results (which is of course correct because there are no integers such that x % 2 = 3).&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Best regards,&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Mateusz&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 17 Jan 2018 10:21:14 GMT</pubDate>
    <dc:creator>MateuszCh</dc:creator>
    <dc:date>2018-01-17T10:21:14Z</dc:date>
    <item>
      <title>Layer definitions queries don't work in the ArcGis Server 10.4</title>
      <link>https://community.esri.com/t5/data-management-questions/layer-definitions-queries-don-t-work-in-the-arcgis/m-p/670416#M38015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Hi,&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I am developing an application using ArcGis Runtime v100.2 and ArcGis server v10.4.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I have a layer with multiple objects with the same shape and I'm using layer definition queries to select objects which are shown to the user.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;To keep things simple my objects are stored in the database in table Objects with columns itemId, value, timestamp and shape.&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Items with the same itemId have always the same shape and for one timestamp one itemId can have at most one value.&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;The approach works if the definition query is very simple (e.g. timestamp = '2018-01-01 12:00') but it doesn't work&amp;nbsp;when I use something more complicated like (selecting most recent value for given point in time):&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;timestamp = (select max(timestamp) from Objects t2 where timestamp &amp;lt;=&amp;nbsp; '2018-01-16 17:00' and itemId = t2.itemId )&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;In such case always all objects are shown. Moreover I cannot find any error or warning message anywhere.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;(Documentation suggests using IN instead of first = but the query doesn't work both cases.)&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;The same behaviour I see when I use the web REST interface.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I have tried profiling the database, and it seems that the query isn't run in the database at all.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;I have also tried running the same query in the ArcMap 10.4 and it works fine there (and I can see the query in DB profiler) so I believe that the query must be correct. It of course works also if run directly in the DB.&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;My questions are:&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;1. What do I do wrong?&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;2. Are the errors in layer definition queries logged anywhere?&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;3. Is there any detailed information about layer definitions query syntax?&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;For quick tests the query that also doesn't work in the REST interface but works in the ArcMap is:&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;itemId % 2 = 3&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Where itemId can be&amp;nbsp;any integer column, % is the&amp;nbsp;MOD operation. In the REST interface it returns all items (and it's not run against the database) and in the ArcMap it rerurns no results (which is of course correct because there are no integers such that x % 2 = 3).&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Best regards,&lt;/DIV&gt;&lt;DIV style="color: #222222; font-size: small;"&gt;Mateusz&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jan 2018 10:21:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/layer-definitions-queries-don-t-work-in-the-arcgis/m-p/670416#M38015</guid>
      <dc:creator>MateuszCh</dc:creator>
      <dc:date>2018-01-17T10:21:14Z</dc:date>
    </item>
  </channel>
</rss>

