You need to sign in to do that
Don't have an account?
loneboat
When updating via DML statement, need all fields?
Suppose I have an object type A with fields A.Id, A.a, A.b, A.c.
If I want to update ONLY field A.a, do I have to select ALL the fields if I want to retain their present values?
E.g.:
A x = [SELECT Id, a FROM A WHERE A.Id=:someIdValue]; x.a='asdf'; update x;
Would this wipe out x.b and x.c, since they were not selected and were thus empty when I called "update"?
Also, can I change values which were NOT selected:
A x = [SELECT Id, a FROM A WHERE A.Id=:someIdValue]; x.a='asdf'; x.b='qwer'; x.c='zxcv'; update x;
Thanks!
No, you only need the fields you are going to update. The other fields won't be blanked as they don't really exist on that instance.
All Answers
No, you only need the fields you are going to update. The other fields won't be blanked as they don't really exist on that instance.
Excellent, thanks for the reply.
How about the second question - can I update fields which were not selected?
Sorry, missed that one. Yes you can.
E.g.
When I run this in the debug log, I'm able to update the phone number.