首页 > 代码库 > 59、salesforce实现数据的批量处理
59、salesforce实现数据的批量处理
批处理,往自己的邮箱发一封邮件,批处理采用异步的处理方式处理数据,最多可以处理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实现数据的批量处理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。