rawInsertAll method

Future<BoolCommitResult> rawInsertAll(
  1. String pSql,
  2. List? params, {
  3. bool? exclusive,
  4. bool? noResult,
  5. bool? continueOnError,
})

Implementation

Future<BoolCommitResult> rawInsertAll(String pSql, List<dynamic>? params,
    {bool? exclusive, bool? noResult, bool? continueOnError}) async {
  final result = BoolCommitResult(success: false);
  // If there is no open transaction, start one
  final bool closeBatch = !await batchStart();

  for (var t in params!) {
    openedBatch[_dbModel!.databaseName!]!
        .rawInsert(pSql, t.toArgsWithIds() as List<dynamic>);
  }

  if (closeBatch) {
    try {
      result
        ..commitResult = await batchCommit(
            exclusive: exclusive,
            noResult: noResult,
            continueOnError: continueOnError)
        ..success = true;
    } catch (e) {
      result.errorMessage = e.toString();
      print('SQFENTITY ERROR while run execSQLList:');
      print(result.toString());
      rethrow;
    }
    openedBatch[_dbModel!.databaseName!] = null;
  } else {
    result.success = true;
  }

  return result;
}