bulkInsert method
Performs a bulk insert operation using the native ODBC bulk insert API.
The connectionId must be a valid active connection.
The table is the target table name.
The columns list specifies the column names in order.
The dataBuffer contains the raw data bytes in the format specified
by the BulkInsertBuilder class.
The rowCount specifies how many rows are in the buffer.
Returns the number of rows inserted on success.
Implementation
Future<Result<int>> bulkInsert(
String connectionId,
String table,
List<String> columns,
List<int> dataBuffer,
int rowCount,
) async {
if (table.trim().isEmpty) {
return const Failure<int, OdbcError>(
ValidationError(message: 'Table name cannot be empty'),
);
}
if (columns.isEmpty) {
return const Failure<int, OdbcError>(
ValidationError(message: 'At least one column required'),
);
}
if (rowCount < 1) {
return const Failure<int, OdbcError>(
ValidationError(message: 'Row count must be at least 1'),
);
}
return _repository.bulkInsert(
connectionId,
table,
columns,
dataBuffer,
rowCount,
);
}