execSQL method

Future<BoolResult> execSQL(
  1. String pSql, [
  2. List? arguments
])

Run sql command with arguments (arguments is optional)

Implementation

Future<BoolResult> execSQL(String pSql, [List<dynamic>? arguments]) async {
  final BoolResult result = BoolResult(success: false);

  try {
    if (openedBatch[_dbModel!.databaseName!] == null) {
      final Database db = (await this.db)!;
      await db.execute(pSql, arguments);
      result
        ..success = true
        ..successMessage = 'sql command executed successfully';
    } else {
      openedBatch[_dbModel!.databaseName!]!.execute(pSql, arguments);
      result
        ..success = true
        ..successMessage = 'sql command added to batch successfully';
    }
  } catch (e) {
    result.errorMessage = e.toString();
  }

  return result;
}