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
AlwaysConfusedAlwaysConfused 

can this be done with SOQL?

Hey guys,

 

Just trying to figure out some problems with the data i have in a SQL server database this end and i found that i'm missing about 200 records.

 

Can i do this in SOQL against the API :

 

select field1, field2, fieldx

from Contact

where id in (id1, id2, id3, id4 idx)

 

I tried and the server threw a 500 internal server error at me.

I'm guessing that this is the wrong syntax for soql but what is the equivilent to this sql? 

 

Thanks in advance :)

SuperfellSuperfell

Yes, that should work (remember to quote the Ids). You could also call retrieve as well.

AlwaysConfusedAlwaysConfused

Ok ...

 

I'm using the web method "API.QueryAsync(soqlQuery)".

The idea is that I asyncronously make the request and save the batch of results that comes back whilst in another thread calling "API.QueryMore(QueryLocator)".

 

Most of my queries contain result sets in the millions, I found this to be the most efficient use of resources.

 

I'm not doing anything not recommended and if we are both right there's nothing wrong with my query.

 

I've also had this problem with other queries, as soon as I start using where clauses the server throws internal server errors at me (500).

 

Any ideas how I should proceed from here?

 

Thanks for the feedback (in advance)

SuperfellSuperfell

There a limt of 10K for the length of the SOQL query, so if you have lots of Ids you're going to blow past that 10k limit.

AlwaysConfusedAlwaysConfused

Ok i'm having to take another aproach now as I need to identify the missing records from about 2.7 million that I need to fetch and using that query simply wont work.

 

In short i have only 1 reasonable option.

 

1. I download a complete backup (1 off).

2. Insert the lot in to SQL this end.

3. Daily / weekly pull all records where the LastUpdatedDate > last time I synch'ed.

 

That way most of the time I only pull say 100 to 1k records, but occasionally i get the odd blip where something major has been done where i need to pull say 500k .

 

That's a whole other problem though.

 

Still find it odd that the where id in(id list) didn't work though, been getting wierd bits like this reguarly.

 

Anyone else had peculiar apparently fine queries not work?

gsmithfarmergsmithfarmer

We backup directly into a local relational database using http://code.google.com/p/sqlforce/wiki/CopyForce

 

The tool is cheap enough (on transaction counts) to run every day and also does incremental backups.

Best of all it is open source.

 

If you just want a backup for safety, I recommend CopyForceH2.

If you want to use the data, then go with CopyForceSQlServer or CopyForceOracle.