startの中、getQueryLocatorはbigobjectが扱うことができないです。
iteratorを入れ替えて、解決する。
下記のはサンプルコードです
bigobjectのDML操作は普通のオブジェクトのDML操作と同時に実行できないから、
APIを経由して操作は可能です。
もし、deleteinmidiateを使った場合、上記を注意してください
PS
bigobjectを削除するには、apexかsoap apiしかできない、dataloaderはできないです
public with sharing class DeleteBigObjectBatch implements Database.batchable<sObject>,Database.AllowsCallouts {
public Iterable<sObject> start(Database.BatchableContext BC){
return [select index1,index2,index3 from test__b];
}
public void execute(Database.BatchableContext BC, List<sObject> scope){
calloutclass.makePostCallout((List<test__b>) scope);
}
public void finish(Database.BatchableContext BC) {
// Access initialState here
}
}
public class calloutclass {
public static HttpResponse makePostCallout(List<test__b> dl) {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(Url.getOrgDomainUrl().toExternalForm()+'/services/Soap/c/59.0');
request.setMethod('POST');
request.setHeader('Content-Type', 'text/xml');
request.setHeader('SOAPAction', 'delete');
//request.setBody('<?xml version="1.0" encoding="utf-8" ?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><urn:login xmlns:n1="urn:partner.soap.sforce.com"><urn:username>xxxxxx</urn:username><urn:password>xxxxxxxx</urn:password></urn:login></env:Body></env:Envelope>');
String requestString = '<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">';
requestString += '<soapenv:Header>';
requestString += '<urn:SessionHeader>';
requestString += '<urn:sessionId>';
requestString += userinfo.getSessionId();
requestString += '</urn:sessionId>';
requestString += '</urn:SessionHeader>';
requestString += '</soapenv:Header>';
requestString += '<soapenv:Body>';
requestString += '<urn:deleteByExample>';
for(test__b d:dl){
requestString += '<urn:sObjects xsi:type="urn1:test__b" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
requestString += '<index1>' + d.index1 + '</index1>';
requestString += '<index2>' + d.index2 + '</index2>';
requestString += '</urn:sObjects>';
}
requestString += '</urn:deleteByExample>';
requestString += '</soapenv:Body>';
requestString += '</soapenv:Envelope>';
request.setBody(requestString);
system.debug( request.getBody());
request.setHeader('Content-Length', '0');
HttpResponse response = http.send(request);
// Parse the JSON response
if(response.getStatusCode() == 200) {
System.debug('実行成功: ' + response.getStatusCode() + ' ' + response.getStatus());
System.debug(response.getBody());
} else {
System.debug(response.getBody());
}
return response;
}
}