Supported SQL functions in ArcGIS Server

By default, ArcGIS Server enforces standardized queries, which requires developers to use standardized SQL queries when working with map, feature, image, and WFS services through REST or SOAP. This helps prevent SQL injection attacks. For more information, see About standardized queries.

If you're an application developer that is currently using database-specific where clause syntax, you'll need to update the where clauses in your application's code to use common SQL syntax supported by ArcGIS Server. The following list shows which SQL functions are supported and the syntax for each. When the following functions and syntax are used in your applications, ArcGIS Server converts them to conform to the specification of the database used by the service.

Function type

Function

Description

Example

Notes

Date

CURRENT_DATE

Returns the current date in the session time zone.

Datefield < CURRENT_DATE

Only the following date and timestamp syntax is supported:

date 'yyyy-mm-dd', for example, Datefield = date '2012-05-29'

timestamp 'yyyy-mm-dd hh:mm:ss', for example, Datefield = timestamp '2012-05-29 15:14:25'

CURRENT_TIMESTAMP

Returns the current local time.

Timestampfield < CURRENT_TIMESTAMP

EXTRACT(extract_field FROM extract_source)

Returns a single part of the date/time, such as year, month, day, hour, minute, etc.

The extract_field argument can be one of the following keywords: YEAR, MONTH, DAY, HOUR, MINUTE, or SECOND.

Search all rows from the month of November:

EXTRACT(MONTH FROM Datefield) = 11

Math

ABS(numeric_exp)

Returns the absolute (positive) value of the specified numeric expression.

CEILING(numeric_exp)

Returns the smallest integer greater than, or equal to, the specified numeric expression.

FLOOR(numeric_exp)

Returns the largest integer less than or equal to the specified numeric expression.

LOG(float_exp)

Returns the natural logarithm of the specified float expression.

LOG10(float_exp)

Returns the base-10 logarithm of the specified float expression.

POWER(numeric_exp, integer_exp)

Returns the value of the specified expression to the specified power.

POWER(Numericfield, 2) = 16

ROUND(numeric_exp, integer_exp)

Returns a numeric value, rounded to the specified length or precision.

TRUNCATE(numeric_exp, integer_exp)

Returns a numeric value without rounding the value to a specific length or precision.

String

CHAR_LENGTH(string_exp)

Returns the length in characters of the input string.

CONCAT(string_exp1, string_exp2)

Returns a string that is the result of concatenating two or more string values.

LOWER(string_exp)

Returns a character expression after converting uppercase character data to lowercase.

SUBSTRING(string_exp FROM start FOR length)

Returns part of a character or text expression.

Search all rows where the first two characters from values in Stringfield are Ch:

SUBSTRING(Stringfield FROM 1 FOR 2)='Ch'

UPPER(string_exp)

Returns a character expression with lowercase character data converted to uppercase.

9/1/2015