Skip to main content

SLAM_download_job

Overview​

If the client disconnects, Speediful can re-download the bulk jobs it submitted. It does not work for jobs submitted by other applications or clients. Use it to recover when something goes wrong on the client machine. You need the bulk job id, which can be retrieved from SLAM_list_jobs or the Salesforce Setup in your browser.

For bulk query jobs, the response is downloaded to the destination table specified in @table.

For Bulk v1 load jobs, set @table to the name of the input table from the originating load operation, or the operation fails. Speediful updates its Id and SLAM_message columns.

For Bulk v2 load jobs, three tables are created from the @table parameter to store the result of the job:

  • <table_name>_successful
  • <table_name>_failed
  • <table_name>_unprocessed

These can be manually correlated back to the input table via the External Id

@exists_action applies to each of these 3 tables, not to @table itself. With 'fail', the procedure fails before writing anything if any of the 3 tables already exists. With 'drop-after', a successful run drops the renamed copy of each table it replaced.

Parameters​

NameTypeDefaultDescription
@job_idNVARCHARRequiredSalesforce bulk job ID to download results for (either 15 or 18-character id)
@tableNVARCHARRequiredFor bulk query jobs: Destination table for query results
For Bulk v1 load jobs: The original input table name, otherwise the operation will fail
For Bulk v2 load jobs: Desired destination table root name. Three result tables will be created from it
@exists_actionVARCHAR(20)NULLControls the behavior when a destination table name is already used. For bulk query jobs, the destination is @table. For Bulk v2 load jobs, the destinations are the 3 result tables named from @table, and @table itself is not checked. Applicable to bulk query jobs and Bulk v2 load jobs only. If NULL, uses the value from SLAM_Settings.default_exists_action (defaulted to 'drop' during initial setup).

Valid options:

  • 'drop' - Drop the existing object and create a new one (default)
  • 'rename' - Rename the existing object by appending a timestamp suffix (format: _YYYYMMDDTHHMMSS_MMM)
  • 'append' - Add the rows to the existing table and keep the rows already in it. See Appending to an existing table
  • 'fail' - Throws a SQL exception if the destination object already exists
  • 'drop-after' - Like 'drop', but keeps the existing object, renamed, until the run succeeds. See The drop-after option

Usage Examples​

Bulk Query - Download results from a completed Bulk v1 or Bulk v2 query job:

EXEC dbo.SLAM_query_bulk
@query = 'Account',
@table = 'Account_query'

-- Some interruption happens during query job

EXEC dbo.SLAM_download_job
@job_id = '7503C00123456789AAA',
@table = 'Account_query'

Bulk v1 - Download results from a completed data load job:

EXEC dbo.SLAM_load_bulk
@sObject = 'Account',
@table = 'Account_LOAD',
@operation = 'insert'

-- Some interruption happens during loading process

EXEC dbo.SLAM_download_job
@job_id = '7504D00987654321AAA',
@table = 'Account_LOAD'

Bulk v2 - Download results from a completed data load job:

EXEC dbo.SLAM_load_bulkv2
@sObject = 'Account',
@table = 'Account_LOAD',
@operation = 'insert'

-- Some interruption happens during loading process

EXEC dbo.SLAM_download_job
@job_id = '7504D00987654321AAA',
@table = 'Account_LOAD_results'

SELECT * FROM Account_LOAD_results_successful
SELECT * FROM Account_LOAD_results_failed
SELECT * FROM Account_LOAD_results_unprocessed