If you want to append to the Body, you first need to extract the value of the Body Blog as a string so you can append. Try this:
Blob firstBlob = Blob.valueOf('test');
String firstString = firstBlob.toString();
Blob secondBlob = Blob.valueOf(firstString + 'test');
System.debug(secondBlob.toString());
For a concrete example, try this:
Account acct = [SELECT Id FROM Account LIMIT 1];
Attachment attch = new Attachment();
attch.ParentId = acct.Id;
attch.Name = 'Data2';
attch.Body = Blob.valueOf('test');
insert attch;
String blob2String = attch.Body.toString();
Blob secondBlob = Blob.valueOf(blob2String + 'secondtest');
System.debug(secondBlob.toString());
attch.Body = secondBlob;
update attch;
system.debug(LoggingLevel.ERROR,attch);
This outputs 'testsecondtest' for me.
I'm not sure of what the d
object is, but I suspect that you should try to catch the error on insert - because it's probably unrelated to the Blob
+=
try with only=