Select to view content in your preferred language

RPC Fault faultString when trying to use database in layer

3080
5
03-30-2011 08:18 AM
DaviKucharski
Deactivated User
Hello. I have the following code that works on a layer that has a data source of the database/table. I get the following error on the queryTask.Execute if the red line highlighted is used. I get no errors and the correct results if I use the line highlighted in Blue. It must have something to do with permissions or the userid/password the system is trying to use to select from. The layer itself comes up, just the Query fails. I do know that the column ID_ exists and the layer has the Query option checked on.
[RPC Fault faultString="Unable to complete operation." faultCode="400" faultDetail="Unable to complete Query operation."]

code
var queryTask:QueryTask = new QueryTask("http://dg2k8esridev1/ArcGISDevelopment/rest/services/ZipCodesDemographics_FromFile/MapServer/2");
var query:Query = new Query();
query.where = "ID_ = '60462'";
query.where = "ID_ in (select distinct zip_code from dg2k3sqltest1.reference.dbo.ref_zip_codes where ref_sources_id = 25)";
query.outSpatialReference = map.spatialReference;
query.returnGeometry = true;
query.outFields = [ "ID_" ];
queryTask.execute(query, new AsyncResponder(onResult, onFault));
Tags (2)
0 Kudos
5 Replies
RobertScheitlin__GISP
MVP Emeritus
Davi,

   Sub-queries inside a Where clause are not supported by the queryTask.

Any valid SQL where clause operating on the fields in the layer is allowed


http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/tasks/supportClasses/Query.html
0 Kudos
DaviKucharski
Deactivated User
Robert,

First, thank you for your response. I am new to the ArcGIS API for Flex. If the query and queryTask will not allow me to join against another database table, do you know of a way for me to do this.

My example is my Layer is of all Zip Codes (33,000 records somewhat). When I drill down into an area I want to only highlight the zip codes that the client has requested. This could be a large list of zip codes so I am holding them in a temp table on my database. I don't see passing a list on the querystring as acceptable. I was hoping to somehow use the layer and temp table to highlight only the zip codes in the temp table. This was available in ArcIMS.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Davi,

   As sub-queries are not supported. The only way I see to do this is with two query tasks as long as ref_zip_codes is a registered standalone table in a geodatabase and you are using ArcGIS Server 10 you can run the sub-query first to get the values for the second query (which is what you said you don't see as acceptable).
0 Kudos
DaviKucharski
Deactivated User
Robert,

But I thought a queryTask was used with a Map Resource to query a Layer. This table would be a table of data. I didn't think you could use the queryTask for that. I do see where you are going with the theory of populate 1 queryTask and then use that queryTask as a part of the 2nd queryTask. I just don't see how you would populate the 1st queryTask with something like 'select zip_code from tmp_zipcodes_123456'. Again this temp table would be valid for 1 user and another user would have the temp table of 'select zip_code from tmp_zipcodes_987654'. They would be valid tables in the database but would have no service associated to them because of their availability.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Davi,

   In ArcGIS Server 10 standalone tables can now be queried if they are part of and registered with a geodatabase. But in your case a temp table will be neither so this is not going to work for you.
0 Kudos