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
iqbaliqbal 

Using the queryMore call

Hi All,
I am writing a Java program which will fetch records from SFDC and insert them to Oracle database tables.My query fetches about 20,000 records.But while processing the records i am able to process only the first 2000 records.
I have not set any batchzize(the default batch size being 2000).So to process the remaing records in batches of 2000 ,i have used the queryMore call.But still my program fails to process from the 2001th record onwards.
 
The folowing is the code segment.
try

{

//Get all the Accounts

qr = bindingIM.query("Select Id,Name from Account where RecordTypeId = '012200000004Tsn' or RecordTypeId ='012200000000Cyn' ");

boolean done = false;

if(qr.getSize()>0)

{

System.out.println("Fetched records:"+qr.getSize());

int iCount=0;

while(!done)

{

record_counter=0;

for(record_counter=0;record_counter<qr.getRecords().length;record_counter++)

{

iCount++;

System.out.println("Current record:"+iCount);

Account acct = (Account) qr.getRecords(record_counter);

ID cust_sf_no = null;

cust_sf_no = acct.getId();

String cust_name = acct.getName();

st.addBatch("INSERT INTO SFDC_CHANGE_CUSTOMER(CUST_SF_NO,CUST_NAME) " +

"VALUES('"+cust_sf_no+"','"+cust_name+"') ");

st.executeBatch();

con_id.commit();

}//end of for loop

if (qr.isDone())

{

done = true;

}

else

{

qr = bindingIM.queryMore(qr.getQueryLocator());

}

}//end of while done

 

} //end of if qr.getSize()>0

}//end of try

 

 

Could anyone please help me to solve this issue?....

 

Thanks in advance,

VN

SuperfellSuperfell
what happens, does the queryMore call fail? does it not make the queryMore call?
iqbaliqbal

No,the queryMore call is not failing.But even though i use the queryMore call,i am not able to process from the 2001th record.

When it comes to the 2001th record,the program terminates giving error as :

Error occured:2000.

SuperfellSuperfell
You should probably put something more useful in your catch block to dump out the exception, and a stack trace.
ganeshjganeshj

Hi,

  I think this may be due to the heap size. So while are calling the java client you can try the following command,

If u are calling jar file,

    java -Xmx1024m -jar <jar file name>  

if u are calling just a java class,

    java -Xmx1024mr <class name>

Basically this will increase ur heap size and run the java class.

Thanks,

Ganesh