Standardized SQL functions in ArcGIS Online
ArcGIS Online requires developers to use standardized SQL queries when querying hosted feature layers. Using standardized SQL queries helps prevent SQL injection attacks. All ArcGIS applications support standard SQL queries.
Limitations of standardized queries
Standardized queries are applied to your entire organization; they cannot be disabled for some layers.
Standardized queries are not supported on joins between different workspaces.
Subqueries as a where clause, for example,
POP_2010 = (SELECT min(POP_2010) FROM counties, are not supported.Queries from database services, for example, Microsoft Azure SQL Database, are not supported.
SQL functions that are supported in ArcGIS Online
If you're an app developer currently using database-specific where clause syntax, you'll need to update the where clauses in your app's code to use common SQL syntax supported by ArcGIS Online. The following tables show which SQL functions are supported and the syntax for each. When the following functions and syntax are used in your apps, ArcGIS Online converts them to conform to the specification of the database used by the feature layer.
Date functions
|
Function |
Description |
|---|---|
|
|
Returns the current date in UTC time. What value is displayed depends on the client you're using. In ArcGIS Online, dates are shown in the time zone for your organization or profile. |
|
|
Returns the current UTC date and time (hours, minutes, seconds). What value is displayed depends on the client you're using. In ArcGIS Online, time is displayed in the local time of your organization or profile. |
|
|
Returns the current UTC date and time (hours, minutes, seconds, milliseconds). What value is displayed depends on the client you're using. In ArcGIS Online, time is displayed in the local time of your organization or profile. |
|
|
Returns a single part ( The following examples extract different units from the date time value 2016-12-21 15:11:
|
Numeric functions
|
Function |
Description |
|---|---|
|
|
Returns the absolute (positive) value of the number you specify. |
|
|
Converts a number to a different type. In the first example below, the number is cast to an integer. Because integers are whole numbers, the result is 1424. In the second example, an integer is cast to a float, which results in a number with decimal places, 1424.0
|
|
|
Returns the smallest integer greater than or equal to the specified number. The following example returns 13:
|
|
|
Returns the trigonometric cosine of |
|
|
Returns the largest integer that is less than or equal to the specified number. The following example returns 12:
|
|
|
The natural logarithm of the specified number. |
|
|
The base-10 logarithm of the specified number. |
|
|
Returns the remainder after the dividend (<number>) is divided by the divisor <n>. Both <n> and <number> must be of type integer. Examples include the following:
|
|
|
Returns Whenever a calculation encounters a For example, suppose you need to calculate a double field to be
|
|
|
Returns the value of the specified number raised to the specified power ( The following example returns 32768:
|
|
|
Rounds the number you specify to the specified length. If you use a positive number for the Examples are as follows:
|
|
|
Returns the trigonometric sine of the specified |
|
|
Returns the tangent of the specified |
|
|
Truncates the A positive In the first example, the numbers to the right of the decimal place are truncated to include only two numbers, resulting in the value 111.99. In the second example, the numbers to the left of the decimal place are truncated, resulting in the value 100.00.
|
String functions
|
Function |
Description |
|---|---|
|
|
Converts the string to a date or time if the string value is in a supported format. If the string is in the format 'MM/DD/YYYY hh:mm:ss' or 'YYYY-MM-DD', you can cast it to a date. If the string is in the format 'HH:MM:SS', you can cast it to the time only data type ( For example, the follow string can be cast to a date:
|
|
|
Returns the number of characters in the specified string. The result is an integer. For example, the following statement returns 8:
|
|
|
Concatenates two string values. Only two strings can be provided. To concatenate more than two strings, nest consecutive The first example below concatenates the letters A and B. The second example shows a nested
Null values are converted to an empty string. |
|
|
When the For example, if the user, planner3, is signed in to the organization to access a hosted feature layer view that contains the following query definition, only features where the staffmember field contains the value planner3 are returned to the connecting user:
In the next example, multiple values are stored in the staffmember field. The following
|
|
|
Returns the position of the first occurrence of the specified substring in the string you specify. If the specified substring is not found, the result is 0. In the first example below, the result is 5 because the first letter (b) of the substring (boat) is the fifth letter in the string (Sailboat). In the second example, the result is 0, because the substring (motor) is not present in the string.
|
|
|
Returns a part of a string value; See the following examples:
|
|
|
Returns a string where all leading or trailing spaces are removed from the string you specify. In the following example, a space exists before and after the string, San Bernardino. The keyword
This returns the string |
|
|
Returns a string where all characters are converted to uppercase. In this example, all letters in the string Sailboat are converted to uppercase, resulting in the string
|
|
|
Returns a string where all characters are converted to lowercase. In the next example,
|