You need to sign in to do that
Don't have an account?

Count() SOQL exception when no results
Hi,
I am attempting to query the number of rows I have for a particular object, so that if there are 0 objects, I don't operate.
I have tried the following line (this is the first line of code, which is called from an VisualForce ActionButton):
Integer Total_size = [select COUNT() from invoice__c where Week__c = :Current_Week_Ending.id];
I get the following error:
System.NullPointerException: Attempt to de-reference a null object
Any ideas why this happens? how can I verify that there are no objects before I work on it? for now, I will get the list and check it's size, but I think it's less efficient.
Thanks,
Ben
All Answers
Silly me.
Thaks.