码迷,mamicode.com
首页 > 其他好文 > 详细

59、salesforce实现数据的批量处理

时间:2017-02-16 23:57:21      阅读:847      评论:0      收藏:0      [点我收藏+]

标签:message   ini   select   ring   com   ndis   自己   global   .com   

批处理,往自己的邮箱发一封邮件,批处理采用异步的处理方式处理数据,最多可以处理5000万条数据

global with sharing class MerchandiseBatch implements Database.Batchable<sObject>,Database.Stateful{ Integer queryCount = 0; String myEmailAddress = ‘weizhen.zhao@pactera.com‘; global Database.QueryLocator start(database.BatchableContext bc){ String query = ‘select Name from Merchandise__c‘; return Database.getQueryLocator(query); } global void execute (Database.BatchableContext bc,List<Merchandise__c> merchandiseList){ for(Merchandise__c merchandise : merchandiseList){ Decimal price = merchandise.Price__c; price += 1; queryCount +=1; } upsert merchandiseList; } global void finish(Database.BatchableContext bc){ System.debug(‘query count: ‘+ queryCount); Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setToAddresses(new String[]{myEmailAddress}); email.setSubject(‘show count‘);//set subject email.setHtmlBody(‘query Count‘ + queryCount); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email}); } }
MerchandiseBatch merchandise = new MerchandiseBatch();
Id batchId = Database.executeBatch(merchandise);

技术分享

 

59、salesforce实现数据的批量处理

标签:message   ini   select   ring   com   ndis   自己   global   .com   

原文地址:http://www.cnblogs.com/weizhen/p/6407573.html

(2)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!