function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RichardRichard 

complex query with soap api 2.0

Hi.

I'm trying to create a complex query that can be made up of 2-n conditions by parsing a psuedo sql statement. This is working fine when using just 2 statements. when I up this to 3 statements the code bombs out with a stack overflow error.

Algorithmically I am:

creating a simple Query statement.
creating a second simple query statement.
combining these into a complex query using makeAndOrFilter function.

creating a third simple query statement.
combining this into a complex query using the makeAndOrFilter funtion and the previously created complex query.


Is the nesting of queries in this way supported? or can I only create complex queries when I have an even number of query statements to use as the example QueryFilter.java file?

my succesfull soap request is detailed below:


OST /servlet/servlet.SoapApi HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.1
Host: na1-api.salesforce.com
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "sfconnector:SalesforceConnector#query"
Content-Length: 2836





s23uXwpju4AY_wPjB1t.K.VclJYSpLhLHkoVtihD5pMHQNt0.3NyFs6j_tlxtBQiBK_XYAh9q6xyi4Rib7quMvbtzKggVlhL
2.0




filter
user
1

id




value



field
username


value
joe.bloggs@address.com.au


operator
equals




field
firstName


value
Joe


operator
equals





operator
and




1970-02-01T06:03:16.838Z
false


Message Edited by Richard on 10-17-2003 10:26 AM

DevAngelDevAngel

Hi Richard,

You can create complex queries without any restrictions. 

For a query like "select x from a where ((b = c) or (b = d)) and (e < f) and (g contains h or g contains i)" what you have is

((b=c) or (b=d)) or filter1 = filter2 or'd with filter3

(e < f)  or filter4 = simple filter

(g contains h or g contains i) or filter5 = filter6 or'd with filter7

So, now we are down to 3 filters that are and'd together.

filter8 = (filter1 and filter4 and filter5)

These can all be generated and combined using the makeSimpleFilter and other helpers from the sample.  When combining filters into a new filter, remember to use the operands and or or.  This does get complicated very quickly and is difficult to debug.  The good news is that in the next release you will enter an SQL-like string and the service will handle this parsing.

RichardRichard
Dave,

Thanks.
The SQL-esque functionality sounds great. That is pretty much what I am doing now. If I want to use this functionality from the new API will I be able to do that without changing any of the code that I have written using API2.0? ie. replace my sql-esque implementation with that fro the new API whilst still using the same objects etc from API 2.0?


Richard

Message Edited by Richard on 10-17-2003 05:29 PM

adamgadamg
Alas, you'll need to do some recoding. Based on the new functionality, however, I think you'll find it well worth your time You'll never have to directly manipulate XML elements again, and instead get a set a of strongly typed objects to work with that directly represent your organization's data model
Barry LBarry L

You might want to check out a post that I made to the General board.  It takes SQL-like code and returns data.  The underlying API module is written in .NET, but there's a GUI query tool that lets you type the SQL and see the request going to SFDC. 

It does filters of infinite depth and complexity.  If all you need is the XML, you can just copy/paste from the window.

Hope that it helps.

Barry

P.S. be aware that the tool does automatic name standarization, so your field names will have to be entered in it's format when you type the SQL.  It's pretty easy.  Instead of lastName, use LAST_NAME.  The real names will be translated back for the XML.