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
Ali Khan 41Ali Khan 41 

String foo = [select COUNT() from Form__c where UserName__c =: 'username']; I have an error in this code.. i want to count the records that the records is already present in it or not. plzz tell the solution of this error

Best Answer chosen by Ali Khan 41
Ajay K DubediAjay K Dubedi
Hi Ali,

Please try this one.

COUNT() always return an integer value. So, you need to write your query like this.

Integer foo = [SELECT COUNT() FROM Form__c WHERE UserName__c ='username'];

Please mark it as best answer if it helps you.

Thank You,
Ajay Dubedi

All Answers

Ajay K DubediAjay K Dubedi
Hi Ali,

Please try this one.

COUNT() always return an integer value. So, you need to write your query like this.

Integer foo = [SELECT COUNT() FROM Form__c WHERE UserName__c ='username'];

Please mark it as best answer if it helps you.

Thank You,
Ajay Dubedi
This was selected as the best answer
Ali Khan 41Ali Khan 41
Thank u Ajay