Packagecom.esri.ags.tasks
Classpublic class QueryTask
InheritanceQueryTask Inheritance BaseTask Inheritance flash.events.EventDispatcher

Executes a query operation on a single layer or table resource of a Map Service, Feature Service or Image Service exposed by the ArcGIS Server REST API. For map and feature services, the layer can be either a (spatial) layer or a (non-spatial) table. For image services, the map service itself is the 'single' layer.

Set the URL to the ArcGIS Server REST resource that represents a single layer or table, for example, http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5. Note the number "5" at the end of the URL which indicates which specific layer you want to query when querying a map service or a feature service. For an image server, the map service itself is the 'single' layer, so the URL would end with "/MapServer" (without a number).

For more information on constructing a URL, see Using the ArcGIS Services Directory.

See also

com.esri.ags.tasks.supportClasses.Query
com.esri.ags.FeatureSet
com.esri.ags.events.QueryEvent
Concepts - Using Query
Query (Map Service\Layer) [ArcGIS REST API]
Live sample - Query using Dynamic Layer and JoinDataSource
Live sample - Show Query result on Map
Live sample - Query a raster catalog in an ImageService


Public Properties
 PropertyDefined By
 InheritedautoNormalize : Boolean
If true, normalizes the geometries across the central meridian.
BaseTask
 Inheritedconcurrency : String
Value that indicates how to handle multiple calls to the same task.
BaseTask
 InheriteddisableClientCaching : Boolean
If true, adds a timestamp parameter ("_ts") to the REST request to prevent the request from being loaded from the browser's cache.
BaseTask
  executeForCountLastResult : Number
The count returned from last call to the executeForCount function.
QueryTask
  executeForIdsLastResult : Array
Array of "Object Id" returned from last call to the executeForIds function.
QueryTask
  executeLastResult : FeatureSet
FeatureSet returned from last call to the execute function.
QueryTask
  executeRelationshipQueryLastResult : Object
The related records object returned from last call to the executeRelationshipQuery function.
QueryTask
  gdbVersion : String
Geodatabase version to use.
QueryTask
 Inheritedmethod : String
URL request method to use.
BaseTask
 InheritedproxyURL : String
The URL to proxy the request through.
BaseTask
 InheritedrequestTimeout : int
The request timeout in seconds.
BaseTask
 InheritedshowBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
BaseTask
  source : ILayerSource
The dynamic layer source.
QueryTask
 Inheritedtoken : String
Token for accessing a secure task.
BaseTask
 Inheritedurl : String
URL of the task.
BaseTask
  useAMF : Boolean
Use AMF for execute() and executeRelationshipQuery().
QueryTask
Public Methods
 MethodDefined By
  
QueryTask(url:String = null)
Creates a new QueryTask object used to execute a query on the layer or table resource identified by the URL.
QueryTask
  
execute(query:Query, responder:IResponder = null):AsyncToken
Executes a query against an ArcGIS Server map layer or table.
QueryTask
  
executeForCount(query:Query, responder:IResponder = null):AsyncToken
Gets the count of features that satisfy the input query.
QueryTask
  
executeForIds(query:Query, responder:IResponder = null):AsyncToken
Executes a query against an ArcGIS Server map layer or table.
QueryTask
  
executeRelationshipQuery(relationshipQuery:RelationshipQuery, responder:IResponder = null):AsyncToken
The executeRelationshipQuery operation is performed on a layer (or table) resource.
QueryTask
Protected Methods
 MethodDefined By
 Inherited
sendURLVariables(urlSuffix:String, urlVariables:URLVariables, responder:IResponder, operation:Function):AsyncToken
Sends an HTTP request.
BaseTask
Events
 Event Summary Defined By
  Dispatched when an execute operation successfully completes.QueryTask
  Dispatched when an executeForCount operation successfully completes.QueryTask
  Dispatched when an executeForIds operation successfully completes.QueryTask
  Dispatched when an executeRelationshipQuery operation successfully completes.QueryTask
  Dispatched when a QueryTask fails.QueryTask
Property Detail
executeForCountLastResultproperty
executeForCountLastResult:Number

Since : ArcGIS API for Flex 2.2

The count returned from last call to the executeForCount function.

This property can be used as the source for data binding.


Implementation
    public function get executeForCountLastResult():Number
    public function set executeForCountLastResult(value:Number):void
executeForIdsLastResultproperty 
executeForIdsLastResult:Array

Array of "Object Id" returned from last call to the executeForIds function.

This property can be used as the source for data binding.


Implementation
    public function get executeForIdsLastResult():Array
    public function set executeForIdsLastResult(value:Array):void
executeLastResultproperty 
executeLastResult:FeatureSet

FeatureSet returned from last call to the execute function.

This property can be used as the source for data binding.


Implementation
    public function get executeLastResult():FeatureSet
    public function set executeLastResult(value:FeatureSet):void
executeRelationshipQueryLastResultproperty 
executeRelationshipQueryLastResult:Object

The related records object returned from last call to the executeRelationshipQuery function.

This property can be used as the source for data binding.


Implementation
    public function get executeRelationshipQueryLastResult():Object
    public function set executeRelationshipQueryLastResult(value:Object):void

See also

gdbVersionproperty 
gdbVersion:String

Since : ArcGIS API 3.0 for Flex

Geodatabase version to use. Requires ArcGIS 10.1 or later (and versioned data).

This property can be used as the source for data binding.


Implementation
    public function get gdbVersion():String
    public function set gdbVersion(value:String):void
sourceproperty 
source:ILayerSource

The dynamic layer source. Required when the url is "http://<mapservice-url>/dynamicLayer".

This property can be used as the source for data binding.


Implementation
    public function get source():ILayerSource
    public function set source(value:ILayerSource):void
useAMFproperty 
useAMF:Boolean

Since : ArcGIS API for Flex 2.0

Use AMF for execute() and executeRelationshipQuery(). Requires the server to be ArcGIS Server 10.0 or above, set to false if using earlier server versions. When useAMF is true, the BaseTask properties concurrency, requestTimeout and showBusyCursor are ignored.

The default value is true.

This property can be used as the source for data binding.


Implementation
    public function get useAMF():Boolean
    public function set useAMF(value:Boolean):void
Constructor Detail
QueryTask()Constructor
public function QueryTask(url:String = null)

Creates a new QueryTask object used to execute a query on the layer or table resource identified by the URL.

Parameters
url:String (default = null) — [optional] URL to the ArcGIS Server REST resource that represents a map layer or table.
Method Detail
execute()method
public function execute(query:Query, responder:IResponder = null):AsyncToken

Executes a query against an ArcGIS Server map layer or table. The result is returned as a FeatureSet. If the query is successful, the user-specified responder is invoked with the result. A FeatureSet contains an array of Graphic features, which can be added to the map using GraphicsLayer.add(). This array will not be populated if no results are found.

Parameters

query:Query — Specifies the attributes and spatial filter of the query.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
executeForCount()method 
public function executeForCount(query:Query, responder:IResponder = null):AsyncToken

Since : ArcGIS API for Flex 2.2

Gets the count of features that satisfy the input query. The result is returned as a Number. If the query is successful, the user-specified responder is invoked with the result.

Parameters

query:Query — Specifies the attributes and spatial filter of the query.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
executeForIds()method 
public function executeForIds(query:Query, responder:IResponder = null):AsyncToken

Executes a query against an ArcGIS Server map layer or table. The result is returned as an array of object ids. If the query is successful, the user-specified responder is invoked with the result.

Parameters

query:Query — Specifies the attributes and spatial filter of the query.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
executeRelationshipQuery()method 
public function executeRelationshipQuery(relationshipQuery:RelationshipQuery, responder:IResponder = null):AsyncToken

The executeRelationshipQuery operation is performed on a layer (or table) resource. The result of this operation are featuresets grouped by source layer (or table) object IDs. Each featureset contains Feature objects including the values for the fields requested by the user. For related layers, if you request geometry information, the geometry of each feature is also returned in the featureset. For related tables, the featureset does not include geometries.

Parameters

relationshipQuery:RelationshipQuery — Specifies the attributes and spatial filter of the relationshipQuery.
 
responder:IResponder (default = null) — The responder to call on result or fault.

Returns
AsyncToken
Event Detail
executeComplete Event
Event Object Type: com.esri.ags.events.QueryEvent
QueryEvent.type property = com.esri.ags.events.QueryEvent.EXECUTE_COMPLETE

Dispatched when an execute operation successfully completes.

Defines the value of the type property of an executeComplete event object.
executeForCountComplete Event  
Event Object Type: com.esri.ags.events.QueryEvent
QueryEvent.type property = com.esri.ags.events.QueryEvent.EXECUTE_FOR_COUNT_COMPLETE

Dispatched when an executeForCount operation successfully completes.

Defines the value of the type property of an executeForCountComplete event object.
executeForIdsComplete Event  
Event Object Type: com.esri.ags.events.QueryEvent
QueryEvent.type property = com.esri.ags.events.QueryEvent.EXECUTE_FOR_IDS_COMPLETE

Dispatched when an executeForIds operation successfully completes.

Defines the value of the type property of an executeForIdsComplete event object.
executeRelationshipQueryComplete Event  
Event Object Type: com.esri.ags.events.QueryEvent
QueryEvent.type property = com.esri.ags.events.QueryEvent.EXECUTE_RELATIONSHIP_QUERY

Dispatched when an executeRelationshipQuery operation successfully completes.

fault Event  
Event Object Type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

Dispatched when a QueryTask fails.