Query Task with Oracle date

4476
4
05-28-2013 07:15 AM
AdrianMarsden
Occasional Contributor III
Hi

I'm having issues with a query task against data in an Oracle SDE

I have tried


       queryTask = new esri.tasks.QueryTask("http://........../MapServer/0");


        //build query filter
        query = new esri.tasks.Query();
        query.returnGeometry = false;
        query.outFields = ['*'];
        query.where = "DATE_CREATED > TO_DATE('2004-10-04 00:00:00','YYYY-MM-DD HH24:MI:SS')";
        queryTask.execute(query, showResults);




But get  -

dojo.io.script error
Error {code: 400, message: "Unable to complete operation.", details: Array[0], log: undefined}





not sure what else to try, the query as shown works fine in ArcMap (where I copied it from)

Cheers

ACM

0 Kudos
4 Replies
VinayBansal
Occasional Contributor II
Are you getting this error always or in alternate querying....

try adding this to your query
var random = (new Date()).getTime();
  "DATE_CREATED > TO_DATE('2004-10-04 00:00:00','YYYY-MM-DD HH24:MI:SS') AND " + random + "=" + random;

Since there is issue with ArcGIS Server 10.1 with alternate querying(http://support.esri.com/en/bugs/nimbus/TklNMDg2MzQ5) it return error code 400 " Unable to complete operation"
0 Kudos
AdrianMarsden
Occasional Contributor III
Thanks for that - we do use 10.1, but alas the dirtying of the query still produced the same error.  Changing the query to a simple text based comparison does work  (so, refval = "1234/abc" works)

Cheers

Acm
0 Kudos
SadanandacharB1
New Contributor III

To include the date in where clause need to use standard sql syntax, and also it will not support sub queries, I had the same issue in SL api & Arcgis server 10.2.1, it solved when I changed like below :

featureLayer.Where = "SURVEY_DATE >= date '" + dpFromDate.SelectedDate.Value.ToString("yyyy-MM-dd")

+ "' and SURVEY_DATE <= date '" + dpToDate.SelectedDate.Value.ToString("yyyy-MM-dd") + "'";

for more info ref the link, this may help  ArcGIS Help (10.2, 10.2.1, and 10.2.2)

0 Kudos
MohammedEl_Shafaey
New Contributor III

Hi Andrian,

Try this

query.where = "DATE_CREATED > to_date('10/04/2004 00:00','MM/DD/YYYY HH24.MI')";

0 Kudos