Skip to main content

ProcedureBuilder

Struct ProcedureBuilder 

Source
pub struct ProcedureBuilder<'a, S: ConnectionState> { /* private fields */ }
Expand description

Builder for constructing stored procedure calls with named parameters.

Created via Client::procedure(). Supports both input and output parameters with type-safe output declarations.

§Example

let result = client.procedure("dbo.CalculateSum")?
    .input("@a", &10i32)
    .input("@b", &20i32)
    .output_int("@result")
    .execute().await?;

// Access the output parameter
let output = result.get_output("@result").expect("output param present");
assert_eq!(output.value, SqlValue::Int(30));

Implementations§

Source§

impl<'a, S: ConnectionState> ProcedureBuilder<'a, S>

Source

pub fn input(&mut self, name: &str, value: &(dyn ToSql + Sync)) -> &mut Self

Add a named input parameter.

The name should include the @ prefix (e.g., "@id"). The value is converted using the same logic as query parameters.

§Example
client.procedure("dbo.UpdateUser")?
    .input("@id", &42i32)
    .input("@name", &"Alice")
    .execute().await?;
Source

pub fn output_int(&mut self, name: &str) -> &mut Self

Add a named output parameter of type INT.

§Example
client.procedure("dbo.GetCount")?
    .output_int("@count")
    .execute().await?;
Source

pub fn output_bigint(&mut self, name: &str) -> &mut Self

Add a named output parameter of type BIGINT.

Source

pub fn output_nvarchar(&mut self, name: &str, max_len: u16) -> &mut Self

Add a named output parameter of type NVARCHAR with the given max length.

Use max_len = 0 for NVARCHAR(MAX).

Source

pub fn output_bit(&mut self, name: &str) -> &mut Self

Add a named output parameter of type BIT.

Source

pub fn output_float(&mut self, name: &str) -> &mut Self

Add a named output parameter of type FLOAT (64-bit).

Source

pub fn output_decimal( &mut self, name: &str, precision: u8, scale: u8, ) -> &mut Self

Add a named output parameter of type DECIMAL with given precision and scale.

Source

pub fn output_raw(&mut self, name: &str, type_info: RpcTypeInfo) -> &mut Self

Add a named output parameter with a raw TypeInfo for uncommon types.

This is an escape hatch for types not covered by the typed output methods.

§Example
use tds_protocol::rpc::TypeInfo;

client.procedure("dbo.GetGuid")?
    .output_raw("@id", TypeInfo::uniqueidentifier())
    .execute().await?;
Source

pub async fn execute(&mut self) -> Result<ProcedureResult>

Execute the stored procedure and return the result.

Sends an RPC request to SQL Server with the accumulated parameters and reads the complete response including result sets, output parameters, and the procedure return value.

Auto Trait Implementations§

§

impl<'a, S> Freeze for ProcedureBuilder<'a, S>

§

impl<'a, S> !RefUnwindSafe for ProcedureBuilder<'a, S>

§

impl<'a, S> Send for ProcedureBuilder<'a, S>
where S: Send,

§

impl<'a, S> Sync for ProcedureBuilder<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for ProcedureBuilder<'a, S>

§

impl<'a, S> UnsafeUnpin for ProcedureBuilder<'a, S>

§

impl<'a, S> !UnwindSafe for ProcedureBuilder<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more