如何对地图中存储的多个对象(记录列表约1000万条)的多个字段执行顶点批量更新?
我有一个自定义设置,用于存储需要更新的对象及其关联字段。 我计划创建一个映射,将对象名称存储为键,将字段列表存储为值。
Map<String, List<String>> objToLongTextFieldsMap = new Map<String, List<String>>();
我需要将键集迭代到对象名称及其关联的字段名称,并将其传递给自定义函数以构建查询字符串并将该查询返回给executeBatch 方法。
查询生成器函数: Utils_PullDataFromObject.generateQuery(strObjectName, objToLongTextFieldsMap.get(strObjectName));
但是,我关心的是确保 Querylocator 只处理在每个事务中未更新的对象记录(例如,如果批量大小为 2000),对于 Account 对象第一次迭代的第一笔交易 - 我将记录列表传递给executeBatch,然后在第二笔交易上 -它必须在迭代中仅处理下一组帐户记录,并且当处理所有帐户记录时,它必须打破对象名称迭代的循环。因此,在下一个事务中,它必须对下一个对象名称重复相同的过程。
I have a custom setting which stores object and its associated fields which need to be updated.
I am planning to create a map to store the object name as key and the list of fields as values.
Map<String, List<String>> objToLongTextFieldsMap = new Map<String, List<String>>();
I need to iterate the keyset to object name and its associated field names and pass this to a custom function to build a query string and return this query to the executeBatch method.
Query generator function: Utils_PullDataFromObject.generateQuery(strObjectName, objToLongTextFieldsMap.get(strObjectName));
However, my concern is to ensure that the Querylocator only processes the sobject records which are not updated in every transaction (say if the batch size is 2000) and for the first transaction on the first iteration of Account object - I pass the records list to executeBatch, then on the second transaction - it must process only the next set of Account records in the iteration and when all Account records are processed, it must break the loop for object names iteration. So on the next transaction, it must repeat the same process for the next object name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不呢?
您将无法在批处理的 start 方法中进行同时在多个可能不相关的对象上运行的查询。 SOQL 没有“union”关键字。
保持简单。将批次标记为“实现有状态”。在 start 方法中选择一个键,构建查询。做你的事。在完成方法中检查是否还有东西要处理并触发新批次。搜索“菊花链”批处理作业。
How about no?
You won't be able to make a query in batch's start method that runs on multiple possibly unrelated objects at same time. SOQL doesn't have "union" keyword.
Keep it simple. Mark the batch as "implements Stateful". In start method pick one of keys, build the query. Do your thing. In finish method check if there's still something to process and fire off new batch. Search for "daisy chaining" batch jobs.