how to return number of rows or records after using upsert
use upsert result attribute CREATED to count number of records which got created and number of records which got updated
Integer createdCount = 0;
Integer updatedCount = 0;
List uResults = Database.upsert(leads,false);
for(Database.upsertResult result:uResults) {
if (result.isSuccess()) {
if(result.isCreated())
createdCount++;
else
updatedCount++;
}

Recent comments
5 weeks 4 days ago
5 weeks 6 days ago