breakExecution method
Interrupt the currently executing database operation.
Sends a break signal to the Oracle server to cancel a long-running operation. This is typically called from a different isolate or in response to user cancellation.
Example - User Cancellation:
// In main isolate - start long query
final queryFuture = connection.query('SELECT * FROM huge_table');
// User clicks cancel button
cancelButton.onPressed = () async {
await connection.breakExecution();
print('Query cancelled');
};
Example - Timeout Protection:
final timeout = Duration(seconds: 30);
try {
await connection.query('SELECT ...').timeout(
timeout,
onTimeout: () async {
await connection.breakExecution();
throw TimeoutException('Query timed out');
},
);
} catch (e) {
print('Operation cancelled or timed out: $e');
}
Warning: After calling breakExecution(), the interrupted operation will fail with an error. You may need to call rollback to clean up the transaction.
See also:
Implementation
Future<void> breakExecution() async {
_ensureConnected();
final result = _dpiOracle.dpiConn_breakExecution(_connectionPtr.value);
if (result == DPI_FAILURE) {
throw OracleConnectionException('Failed to break execution');
}
}