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
TROGTROG 

SOQL Variable Naming Rules/Requirements?

Can anyone please tell me if there is a naming convention, or rules/requirements, for naming SOQL variables?  It took me FOREVER to try figuring out why my test method wasn't working...throwing an " unexpected token: 'List' " error.  I changed the variable name from '1stWR' to 'dupes' and the error went away and it worked.  Frustrating.  I'd like to learn why so I can at least come away with some education...
     
****THIS ONE DIDN'T WORK.  It threw an "unexpected token: 'List' " error.
​ // Now we try to find our 1st well revenue, insuring that the "Dupe Well Data" flag for the initial submission is NOT set.
        List<Well_Revenue__c> 1stWR = [Select ID from Well_Revenue__c
                                       WHERE Name = :wr1.Name
                                       AND Dupe_Well_Data__c = True
                                       Limit 1
                                      ];
        System.assertEquals(0, 1stWR.size());       

***THIS ONE WORKED, after changing the variable name '1stWR' to 'dupes'.
// Now we try to find our 1st well revenue, insuring that the "Dupe Well Data" flag for the initial submission is NOT set.
        List<Well_Revenue__c> dupes = [Select ID from Well_Revenue__c
                                       WHERE Name = :wr1.Name
                                       AND Dupe_Well_Data__c = True
                                       Limit 1
                                      ];
        System.assertEquals(0, dupes.size());
Paul S.Paul S.
I tried to confirm this and couldn't, but I wonder if it had something to do with the variable name starting with a number...