BulkRefresh
Use sfdb.BulkRefresh to update the records in a table that was created by sfdb.BulkQuery. Any new new records will get added to the table, and any exisiting records that have been altered since they were last pulled down form Salesforce will be updated.
SFDB does not currently support deleting records from a table if they have been deleted in Salesforce. You can use the IsDeleted column if you need to know which records have been deleted.
Parameters
@tableName
Data Type: NVARCHAR
Required: ️️✔️
The name of the table that should be refreshed. This table must have been created by sfdb.BulkQuery.
@batchSize
Data Type: NVARCHAR
Required: ❌
Default: 100,000
Data will get be retrieved from Salesforce in batches. This parameter allows you to control the size of those batches.
@Context
Data Type: NVARCHAR
Required: ❌
Default: NULL
The context that this job should be made under. For more information, see Contexts. This should be the same context that the original sfdb.BulkQuery procedure was called under.
Refreshable Queries
A refreshable query is a query that was executed by sfdb.BulkQuery, where the data in the results table can be refreshed. There are some limits on what constitutes a refreshable query:
- The
Idcolumn must have been included in the original query. - The
SystemModstampcolumn must have been included in the original query.
If the original query does not match this criteria, then it is not considered a refreshable query.
Results
The data in the original table created by the sfdb.BulkQuery procedure will be updated with the results of this procedure.
The order of the retrieved data is not guaranteed.
Examples
Select all fields from all Account, put the results into a table called Accounts, and then refresh the data.
EXEC sfdb.BulkQuery 'SELECT * FROM Account', 'Account', 'Accounts'
EXEC sfdb.BulkRefresh 'Accounts'
Select all the contacts whose first name is Chris, and put the results into a table called EveryChris, and then refresh the data.
EXEC sfdb.BulkQuery 'SELECT Id, SystemModstamp, FirstName, LastName FROM Contact WHERE FirstName = ''Chris''', 'Contact', 'EveryChris'
EXEC sfdb.BulkRefresh 'EveryChris'