Skip to main content
All CollectionsLoading
BulkAPIv2Delete
BulkAPIv2Delete
Updated over 4 months ago

Create a load table Example (WAIT)

This example creates a load table called "Account_BulkAPIv2_Wait_Delete". The Id and Error columns are mandatory. Generally, a delete payload would be built up from querying or working with prior replicated data for the affected Object by using ss_Replica / ss_Delta. All load operations require the Error column, whether success or failure, to guide and inform you.

exec ss_Delta 'DEMO', 'Account'

drop table if exists Account_BulkAPIv2_Wait_Delete
select top 100
convert(nchar(18),Id) as Id
,convert(nvarchar(255),null) as Error
,Name as Name_Info
into Account_BulkAPIv2_Wait_Delete
from Account
order by createddate desc

Running the example

exec ss_Loader 'BulkAPIv2Delete', 'DEMO', 'Account_BulkAPIv2_Wait_Delete','WAIT'

SQL-SALES BulkAPIv2Delete run date: 2023-12-09 ------------------

21:42:25: Using Env|Schema: DEMO|dbo

21:42:25: Starting Loader for Account batchsize 10000

21:42:25: SSId added to Account_BulkAPIv2_Wait_Delete

21:42:27: Connection method BULK & BULK API

21:42:27: Bulk API method WAIT

21:42:27: Columns checked against Salesforce metadata

21:42:28: Starting load for Account_BulkAPIv2_Wait_Delete

21:42:42: JobId: 7508d00000TtRuMAAV

21:42:43: Load complete: Success:100 Failure:0

-----------------------------------------------------------------

Note the Job Id for your submission is returned in the output for your reference, see also the log table ss_BulkAPILog.

ss_BulkAPILog table

The Job Id is also preserved in the ss_BulkAPILog table, written on each submission.

Checking the load table

The success or failure errors for each row will be automatically written back to the Error column as with the SOAP API Delete operation.

Create a load table Example (BACK)

This example creates a load table called "Account_BulkAPIv1_BACK_Serial_Delete". The Id and Error columns are mandatory. All load operations require the Error column, whether success or failure, to guide and inform you.

exec ss_Delta 'DEMO', 'Account'

drop table if exists Account_BulkAPIv2_BACK_Delete
select top 100
convert(nchar(18),Id) as Id
,convert(nvarchar(255),null) as Error
,Name as Name_Info
into Account_BulkAPIv2_BACK_Delete
from Account
order by createddate desc

Running the example (Step 1)

exec ss_Loader 'BulkAPIv2Delete', 'DEMO', 'Account_BulkAPIv2_BACK_Delete','BACK'

SQL-SALES BulkAPIv2Delete run date: 2023-12-09 ------------------

21:44:33: Using Env|Schema: DEMO|dbo

21:44:33: Starting Loader for Account batchsize 10000

21:44:33: SSId added to Account_BulkAPIv2_BACK_Delete

21:44:36: Connection method BULK & BULK API

21:44:36: Bulk API method BACK

21:44:36: Columns checked against Salesforce metadata

21:44:36: Starting load for Account_BulkAPIv2_BACK_Delete

21:44:39: JobId: 7508d00000TtUDOAA3

21:44:40: BulkAPIv2Delete BACKGROUND completed successfully

-----------------------------------------------------------------

Note the Job Id for your submission is returned in the output for your reference, see also the log table ss_BulkAPILog.

Note unlike the WAIT method, simply running BACK will not populate the _Batch table nor write back Error data to your load table, see the next set of instructions for how to do this, however the Batch Id(s) are included in the output dump for information purposes

ss_BulkAPILog table

The Job Id is also preserved in the ss_BulkAPILog table, written on each submission.

Running the example (Step 2 Option 1)

At any time after you have run the initial BACK, you can retrieve processed rows to your load table by reverting back to using the WAIT method. This is achieved by passing in the known Job Id into the @Special2 input parameter.

Note, when using “Option 1” if you have attempted to return processed rows “too soon” and some rows for a given Batch or Batches are not yet processed by Salesforce, SQL Sales will not be able to return an Error value hence caution should be exercised and for you to check your load table.

Alternatively, you can use “Option 2” to check the status of your Job by submitting a followup BACK request, alongside your known Job Id. This will instruct SQL Sales to check all related Batches and return the status of the Job Id. When the Job is Closed, no further processing will occur by Salesforce and you can now run with WAIT to return all Id and Error values.

exec ss_Loader 'BulkAPIv2Delete', 'DEMO', 'Account_BulkAPIv2_BACK_Delete','JOB:WAIT','7508d00000TtUDOAA3'

SQL-SALES BulkAPIv2Delete run date: 2023-12-09 ------------------

21:46:28: Using Env|Schema: DEMO|dbo

21:46:28: Starting Loader for Account batchsize 10000

21:46:28: SSId added to Account_BulkAPIv2_BACK_Delete

21:46:31: Connection method BULK & BULK API

21:46:31: Bulk API method JOB:WAIT Job = 7508d00000TtUDOAA3

21:46:31: Columns checked against Salesforce metadata

21:46:31: Starting load for Account_BulkAPIv2_BACK_Delete

21:46:35: JobId: 7508d00000TtUDOAA3, Job Complete

21:46:35: Load complete: Success:100 Failure:0

-----------------------------------------------------------------

Checking the load table

The success or failure errors for each row will be automatically written back to the Error column as with the SOAP API Delete operation.

Running the example (Step 2 Option 2)

You can keep submitting with BACK and the known Job Id until the Status shows that the Job has Closed. Once the Job is Closed you can run as with Option 1.

exec ss_Loader 'BulkAPIv2Delete', 'DEMO', 'Account_BulkAPIv2_BACK_Delete','JOB:BACK','7508d00000TtUDOAA3'

SQL-SALES BulkAPIv2Delete run date: 2023-12-09 ------------------

21:47:59: Using Env|Schema: DEMO|dbo

21:47:59: Starting Loader for Account batchsize 10000

21:47:59: SSId added to Account_BulkAPIv2_BACK_Delete

21:48:02: Connection method BULK & BULK API

21:48:02: Bulk API method JOB:BACK Job = 7508d00000TtUDOAA3

21:48:02: Columns checked against Salesforce metadata

21:48:03: Starting load for Account_BulkAPIv2_BACK_Delete

21:48:06: JobId: 7508d00000TtUDOAA3, Job Complete

21:48:06: BulkAPIv2Delete BACKGROUND completed successfully

-----------------------------------------------------------------


Did this answer your question?