Select to view content in your preferred language

query using getdate fails on 10.2.2

3570
3
Jump to solution
08-06-2014 10:11 AM
MichaelDavis3
Frequent Contributor

Using feature services to create a check-out database for iOS Runtime. 

I noticed that if I try to query the feature services using the getdate() function it fails in 10.2.2 where it worked fine in 10.1 or earlier.

For example - executing a query against the REST endpoint for a feature layer with an AGSDate field using "WHERE dateField > getdate() - 7" will return all records with a date value within the last 7 days.  Works like a charm in 10.1, fails with an error in 10.2

Is this a known bug?

Matt Cooper

0 Kudos
1 Solution

Accepted Solutions
ErinBrimhall
Deactivated User

Hi Michael,

You are most likely running into this change in the REST API at 10.2:

New in 10.2

  • where parameter value must conform to the standardized queries, if the layer / table resource advertises useStandardizedQueries is true. Learn more about standardized queries.

"ArcGIS Server includes a security option that forces developers to use standardized SQL queries when working with map, feature, image, and WFS services through REST or SOAP. This makes it easier for developers and applications to query ArcGIS Server services and helps prevent SQL injection attacks. Standardized queries are enforced by default, but can be disabled by the server administrator."

Disabling standardized queries

If you need to use database-specific where clause statements in your application, you can disable standardized queries by accessing the ArcGIS Server Administrator Directory. To do so, follow the instructions below.

CautionCaution:

By disabling this security option, your site becomes more vulnerable to SQL injection attacks.

Steps:

  1. Open the Administrator Directory and log in with a user that has administrative permissions to your site. The Administrator Directory is typically available athttp://gisserver.domain.com:6080/arcgis/admin.
  2. Click system > properties > update.
  3. On the Operation - update page, enter the following string into the System Properties dialog box:

    {"standardizedQueries": "false"} 

  4. Click Update.
  5. Restart ArcGIS Server.

View solution in original post

0 Kudos
3 Replies
MichaelDavis3
Frequent Contributor

Should have mentioned that this is running SDE against SQL Server.

0 Kudos
ErinBrimhall
Deactivated User

Hi Michael,

You are most likely running into this change in the REST API at 10.2:

New in 10.2

  • where parameter value must conform to the standardized queries, if the layer / table resource advertises useStandardizedQueries is true. Learn more about standardized queries.

"ArcGIS Server includes a security option that forces developers to use standardized SQL queries when working with map, feature, image, and WFS services through REST or SOAP. This makes it easier for developers and applications to query ArcGIS Server services and helps prevent SQL injection attacks. Standardized queries are enforced by default, but can be disabled by the server administrator."

Disabling standardized queries

If you need to use database-specific where clause statements in your application, you can disable standardized queries by accessing the ArcGIS Server Administrator Directory. To do so, follow the instructions below.

CautionCaution:

By disabling this security option, your site becomes more vulnerable to SQL injection attacks.

Steps:

  1. Open the Administrator Directory and log in with a user that has administrative permissions to your site. The Administrator Directory is typically available athttp://gisserver.domain.com:6080/arcgis/admin.
  2. Click system > properties > update.
  3. On the Operation - update page, enter the following string into the System Properties dialog box:

    {"standardizedQueries": "false"} 

  4. Click Update.
  5. Restart ArcGIS Server.

0 Kudos
GaryBarden
Regular Contributor

I'm trying to do something similar within a definition query and it's failing.  Any ideas?

0 Kudos