You need to sign in to do that
Don't have an account?
Queball
Return value of QueryResult.getRecords(). (Partner 6)
Hello all,
I have a question on the return value of a call to QueryResult.getRecords() where the query did not have any returned records. From the documentation we would get in return an instantiated SObject array with length of 0. Is there ever a possibility that this function will return null? Example below.
SoapBinding soapBinding; // Please assume that this is already logged-in.
QueryResult queryResult;
queryResult = soapBinding.query(queryString);
SObject[] sObjects = queryResult.getRecords();
if(sObjects != null){ if(sObject.length > 0){
// do operations on the sObject
}
}
Thanks for the help
I have a question on the return value of a call to QueryResult.getRecords() where the query did not have any returned records. From the documentation we would get in return an instantiated SObject array with length of 0. Is there ever a possibility that this function will return null? Example below.
SoapBinding soapBinding; // Please assume that this is already logged-in.
QueryResult queryResult;
queryResult = soapBinding.query(queryString);
SObject[] sObjects = queryResult.getRecords();
if(sObjects != null){ if(sObject.length > 0){
// do operations on the sObject
}
}
Thanks for the help
Superfell
When an empty array is returned, most toolkits will return null rather than an empty array.
DevAngel
The queryResult also has a size field that indicates how many records matched the query. If the size == 0 then you don't need to even access the getRecords() array.