<?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 REST Query at 9.3.1 with joined data in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/rest-query-at-9-3-1-with-joined-data/m-p/518527#M2468</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have map service in 9.3.1 sp2 which contains a feature class (parcels) joined on "pid" to a table (pdata).&amp;nbsp; All data is contained in the same file gdb and relevant fields are indexed.&amp;nbsp; I'm using 2 different Query operations with different problems ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first query is attribute only with a where clause like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parcels.pid in (select pdata.pid from pdata where upper(pdata.owner) like upper('%[value]%'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above clause works if I choose the default join option of "Keep all records" but it takes 15-20 seconds.&amp;nbsp; However, when using "Keep only matching records", the query fails with an "invalid SQL statement was used" error.&amp;nbsp; If I remove the first "upper" function, the query works and returns the correct results almost instantly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parcels.pid in (select pdata.pid from pdata where pdata.owner like upper('%[value]%'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can I not use the upper function on a table field in a subquery?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second query is a spatial query with a simple envelope for the query geometry.&amp;nbsp; The query should return 19 parcels.&amp;nbsp; If I use the join option of "keep all records", the operation works correctly.&amp;nbsp; However, when "keep only matching" is used, there are some problems...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The query will return the first 500 records of the parcels layer and place them in Africa instead of Florida .. no matter what the spatial query.&amp;nbsp; All of the returned geometries appear to have the correct coordinates and spatial reference.&amp;nbsp; So, that's strange ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The really strange part is that I use the REST Query page directly, with HTML or JSON output, I get the 1st 500 parcels.&amp;nbsp; BUT, if I change the output to KMZ, I get the correct 19 parcels.&amp;nbsp; Nothing else about the query changes except the output format!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears that there is something different in the Query handler when the output format is KMZ that is correct, but is broken with other output formats when a feature class is joined to a table with the "keep only matching" join option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on how I can get both queries to work correctly and efficiently staying with 9.3.1 sp2 and keeping the table dynamically joined to the feature class?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Sep 2010 15:29:42 GMT</pubDate>
    <dc:creator>DavidGreene</dc:creator>
    <dc:date>2010-09-30T15:29:42Z</dc:date>
    <item>
      <title>REST Query at 9.3.1 with joined data</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/rest-query-at-9-3-1-with-joined-data/m-p/518527#M2468</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have map service in 9.3.1 sp2 which contains a feature class (parcels) joined on "pid" to a table (pdata).&amp;nbsp; All data is contained in the same file gdb and relevant fields are indexed.&amp;nbsp; I'm using 2 different Query operations with different problems ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first query is attribute only with a where clause like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parcels.pid in (select pdata.pid from pdata where upper(pdata.owner) like upper('%[value]%'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above clause works if I choose the default join option of "Keep all records" but it takes 15-20 seconds.&amp;nbsp; However, when using "Keep only matching records", the query fails with an "invalid SQL statement was used" error.&amp;nbsp; If I remove the first "upper" function, the query works and returns the correct results almost instantly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;parcels.pid in (select pdata.pid from pdata where pdata.owner like upper('%[value]%'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can I not use the upper function on a table field in a subquery?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second query is a spatial query with a simple envelope for the query geometry.&amp;nbsp; The query should return 19 parcels.&amp;nbsp; If I use the join option of "keep all records", the operation works correctly.&amp;nbsp; However, when "keep only matching" is used, there are some problems...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The query will return the first 500 records of the parcels layer and place them in Africa instead of Florida .. no matter what the spatial query.&amp;nbsp; All of the returned geometries appear to have the correct coordinates and spatial reference.&amp;nbsp; So, that's strange ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The really strange part is that I use the REST Query page directly, with HTML or JSON output, I get the 1st 500 parcels.&amp;nbsp; BUT, if I change the output to KMZ, I get the correct 19 parcels.&amp;nbsp; Nothing else about the query changes except the output format!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears that there is something different in the Query handler when the output format is KMZ that is correct, but is broken with other output formats when a feature class is joined to a table with the "keep only matching" join option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on how I can get both queries to work correctly and efficiently staying with 9.3.1 sp2 and keeping the table dynamically joined to the feature class?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Sep 2010 15:29:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/rest-query-at-9-3-1-with-joined-data/m-p/518527#M2468</guid>
      <dc:creator>DavidGreene</dc:creator>
      <dc:date>2010-09-30T15:29:42Z</dc:date>
    </item>
  </channel>
</rss>

