You need to sign in to do that
Don't have an account?
Sergi
Can't save after adding SOQL query
Hi,
I'm writing an apex class, working with Force.com IDE in Eclipse.
When I add the following line to the code, it doesn't upload the code to the server for an unknown error
c = [SELECT Id, Name FROM Account WHERE Id = :c.Id];
It seems that the problem is in the :c.Id (c is an Account), if I put
Id = 'xxx' //scalar value
in the WHERE section works fine.
Hi There,
Probably the object "c" is NULL until you run the query.
So, when you try to access the field Id using "c.Id", it would lead to a null pointer exception.
Hope this helps!!
Cool_D
The object is not null, I've checked it.
I've been working around and seems that the problem ara the single quotes ' ', it's possible?
I need to quote the c.Id field in the SOQL, how can I do that?
Your problem can't be due to the single quotes. However if you want a way to put single quotes you can use the following method.
But I don't think that it would solve your problem.
String query = 'SELECT Id, Name FROM Account WHERE id = ' + '\'' + c.id + '\'';
sObject conObject = Database.query(query);
c = (Account)conObject;
return c;
In your code you are querying an Account using the id of the same account(Account c).
C = [SELECT Id, Name FROM Account WHERE id = C.Id];
Sometimes the problem may be with that.
Try to print the value of C.Id and make sure that C.Id is not null or empty.