function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NDS.ENDONDS.ENDO 

バッチ処理のシリアル処理について

夜中など特定の時間にAPEXによるバッチ処理を実行したい際、

下記のよう親処理から子処理(バッチ処理1⇒バッチ処理2)を順番に実行しよう記述しましたが、

バッチ処理1の終了を待たず、バッチ処理2が実行されてしまいます。

(思い違いかもしれませんが)

これを回避するには、どうしたら良いでしょうか。

 

 

global class BatchDailyCall implements Schedulable {

    /* 日次バッチの起動 */
    global void execute(SchedulableContext sc) {

        // バッチ処理1
        BatchDaily1 Daily1 = new BatchDaily1();
        Database.executeBatch(Daily1);

        // バッチ処理2
        BatchDaily2 Daily2 = new BatchDaily2();
        Database.executeBatch(Daily2);

    }

ikouikou

バッチは非同期に実行されるので、1の終了を待たずに2が実行されることもあるでしょう。

1と2のスケジューラーを分けるのがベターではないでしょうか。