You need to sign in to do that
Don't have an account?
VN
How to enhance the size of an API create call?
Hi
We have a requirement where we are fetching records from Oracle database and populating it to salesforce system. we are using API create call for this using batching. API create call has a maximum limit of records that it can process.
How can we enhance the size for batching of records for API calls?
Please help.
Thanks
Priya
Cheers
You can move more than 200 records from an Oracle database into a Force.com object with the command line version of Data Loader. I'm not sure if you could use this to address the size of your import, based on the particulars of your requirement, but you will not be limited by the API limitation.
Hope this helps.
This article details how to use Data Loader from the command line. The Data Loader documentation includes descriptions of the configuration files needed to run Data Loader from the command line to access relational databases.
Hope this gives you enough information to create an appropriate solution for you needs.
The other common pattern is to use an accumulator pattern. (this works better when you have an in-determinant and potentially very large number of source rows)
Hi Simon,
Thanks for your response. Iam following the salesforce_platform_cookbook. There is a sample code for batching of records for API calls in page 200.when i paste the code in my program its giving me errors.
This is the sample code iam using.
public SaveResult[] create(SObject[] records, int batchSize)
throws InvalidSObjectFault, UnexpectedErrorFault,
InvalidIdFault, RemoteException,
ServiceException {
if (batchSize > 200 || batchSize < 1)
throw new IllegalArgumentException(
"batchSize must be between 1 and 200");
return batch(records, batchSize, new CreateBatcher());
}
Iam getting syntax error on the first two lines and on the last line error is CreateBatcher cannot be resolved to type.
Please help
Thanks
Priya
public SaveResult[] create(SObject[] records, int batchSize)
throws InvalidSObjectFault, UnexpectedErrorFault,
InvalidIdFault, RemoteException,
ServiceException {
if (batchSize > 200 || batchSize < 1)
throw new IllegalArgumentException(
"batchSize must be between 1 and 200");
return batch(records, batchSize, new CreateBatcher());
}
private SaveResult[] batch(SObject[] records, int batchSize,
Batcher batchOperation)
throws UnexpectedErrorFault, InvalidIdFault,
LoginFault, RemoteException, ServiceException {
if (records.length <= batchSize) {
checkLogin();
return batchOperation.perform(records);
}
SaveResult[] saveResults = new SaveResult[records.length];
SObject[] thisBatch = null;
int pos = 0;
while (pos < records.length) {
int thisBatchSize = Math.min(batchSize,
records.length - pos);
if (thisBatch == null ||
thisBatch.length != thisBatchSize)
thisBatch = new SObject[thisBatchSize];
System.arraycopy(records, pos, thisBatch, 0,
thisBatchSize);
SaveResult [] batchResults = batch(thisBatch,
thisBatchSize,
batchOperation);
System.arraycopy(batchResults, 0, saveResults,
pos, thisBatchSize);
pos += thisBatchSize;
}
return saveResults;
}
private abstract class Batcher {
abstract SaveResult[] perform(SObject [] records)
throws UnexpectedErrorFault, InvalidIdFault,
LoginFault, RemoteException,
ServiceException;
}
private class CreateBatcher extends Batcher {
SaveResult [] perform(SObject [] records)
throws UnexpectedErrorFault, InvalidIdFault,
LoginFault, RemoteException, ServiceException {
checkLogin();
return binding.create(records);
}
}
private class UpdateBatcher extends Batcher {
SaveResult [] perform(SObject [] records)
throws UnexpectedErrorFault, InvalidIdFault, LoginFault,
RemoteException, ServiceException {
checkLogin();
return binding.update(records);
}
}
Again getting the same error at those lines along with many other errors down the code.
Please help.
Thanks
Priya
Hi All,
My code doesn't throw any syntax error now. But iam getting Null Pointer Exception.
This is piece of code.
if (batchSize > 210 || batchSize < 1)
throw new IllegalArgumentException(
"batchSize must be between 1 and 200");
return batch(records, batchSize, x.new CreateBatcher()); /// Exception raised @ this point
}
Please help.
Thanks in advance
Priya