#[non_exhaustive]pub struct ProcedureResult {
pub return_value: i32,
pub rows_affected: u64,
pub output_params: Vec<OutputParam>,
pub result_sets: Vec<ResultSet>,
}Expand description
Result of a stored procedure execution.
Contains the return value, affected row count, output parameters, and any result sets produced by the procedure.
§Example
let result = client.call_procedure("dbo.GetUser", &[&1i32]).await?;
// Check the return value (RETURN statement in the proc)
assert_eq!(result.return_value, 0);
// Process result sets
for mut rs in result.result_sets {
while let Some(row) = rs.next_row() {
let row = row?;
println!("{:?}", row);
}
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.return_value: i32Return value from the stored procedure’s RETURN statement.
Defaults to 0 if the procedure does not explicitly return a value, which matches SQL Server’s default behavior.
rows_affected: u64Total number of rows affected by statements within the procedure.
output_params: Vec<OutputParam>Output parameters returned by the procedure.
result_sets: Vec<ResultSet>Result sets produced by SELECT statements within the procedure.
Implementations§
Source§impl ProcedureResult
impl ProcedureResult
Sourcepub fn get_return_value(&self) -> i32
pub fn get_return_value(&self) -> i32
Get the return value from the stored procedure.
This is the value from the procedure’s RETURN statement.
Defaults to 0 if not explicitly set by the procedure.
Sourcepub fn get_output(&self, name: &str) -> Option<&OutputParam>
pub fn get_output(&self, name: &str) -> Option<&OutputParam>
Get an output parameter by name (case-insensitive).
Strips the @ prefix from both the search name and stored names
before comparing, so get_output("result") and get_output("@result")
are equivalent.
§Example
let result = client.procedure("dbo.CalculateSum")?
.input("@a", &10i32)
.input("@b", &20i32)
.output_int("@result")
.execute().await?;
let output = result.get_output("@result").expect("output param exists");
assert_eq!(output.value, SqlValue::Int(30));Sourcepub fn first_result_set(&self) -> Option<&ResultSet>
pub fn first_result_set(&self) -> Option<&ResultSet>
Get the first result set, if any.
Convenience method for procedures that return a single result set.
Sourcepub fn has_result_sets(&self) -> bool
pub fn has_result_sets(&self) -> bool
Check if the procedure produced any result sets.
Trait Implementations§
Source§impl Clone for ProcedureResult
impl Clone for ProcedureResult
Source§fn clone(&self) -> ProcedureResult
fn clone(&self) -> ProcedureResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more