prepare method
Prepares a SQL statement for execution.
The connectionId must be a valid active connection.
The sql must be a non-empty parameterized SQL statement
(e.g., 'SELECT * FROM users WHERE id = ?').
The timeoutMs specifies the statement timeout in milliseconds
(0 = no timeout).
Returns a statement ID on success, which must be used with
executePrepared and closeStatement.
Returns a ValidationError if SQL is empty.
Implementation
Future<Result<int>> prepare(
String connectionId,
String sql, {
int timeoutMs = 0,
}) async {
if (sql.trim().isEmpty) {
return const Failure<int, OdbcError>(
ValidationError(message: 'SQL cannot be empty'),
);
}
return _repository.prepare(connectionId, sql, timeoutMs: timeoutMs);
}