mapservice layer with definition query fails to execute query on rest site

2434
4
09-23-2016 05:05 PM
BethannMcVicker
New Contributor

I am using ArcGIS 10.3.1 to create and publish mapservices.  I have an Oracle SDE layer with the following definition query: IS_DISPLAYED = 1 ORDER BY ISSUED_DATE ASC.  The expression is successfully verified and displays the correct data in the mxd.  When I publish the mapservice containing this layer as a service, and try to do a query operation from the REST site on this layer, I get the following error: "Failed to execute query."  When I remove the definition query from the layer and re-publish the service, the query works just fine from the REST site.  Is ArcGIS for Server unable to process this type of definition query through the mapservice?  Is there a different definition query I should use instead to get the same results?

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Bethann,

Exert for the ArcGIS Desktop help:

Building a query expression

Because you are selecting columns as a whole, you cannot restrict the SELECT to return only some of the columns in the corresponding table because the SELECT * syntax is hard-coded. For this reason, keywords, such as DISTINCT, ORDER BY, and GROUP BY, cannot be used in an SQL query in ArcGIS except when using subqueries. See SQL reference for query expressions used in ArcGIS for information on subqueries.

0 Kudos
BethannMcVicker
New Contributor

Thanks for the info.  Do you know of a standardized query alternative for the query i'm using?  I looked at the article but didn't see anything that could be substituted for ORDER BY.  If not, I may try disabling standardized queries on my AGS to see if that fixes the problem.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Bethann,

   The work of sorting the results is to be done my the client code that consumes the REST endpoint of the Map Service. For example if using the JS API the Query Class has a orderByFields property that can be set.

by Anonymous User
Not applicable

Apart from expression Check for map services capabilities

is you have enabled query option on this service or not?